diff --git a/base/meta.jl b/base/meta.jl index 4798d37cf9d28..fb4513b639251 100644 --- a/base/meta.jl +++ b/base/meta.jl @@ -13,7 +13,7 @@ export quot, @dump """ - quot(ex)::Expr + Meta.quot(ex)::Expr Quote expression `ex` to produce an expression with head `quote`. This can for instance be used to represent objects of type `Expr` in the AST. See also the manual section about [QuoteNode](@ref man-quote-node). @@ -23,20 +23,20 @@ See also the manual section about [QuoteNode](@ref man-quote-node). julia> eval(quot(:x)) :x -julia> dump(quot(:x)) +julia> dump(Meta.quot(:x)) Expr head: Symbol quote args: Array{Any}((1,)) 1: Symbol x -julia> eval(quot(:(1+2))) +julia> eval(Meta.quot(:(1+2))) :(1 + 2) ``` """ quot(ex) = Expr(:quote, ex) """ - isexpr(ex, head[, n])::Bool + Meta.isexpr(ex, head[, n])::Bool Check if `ex` is an expression with head `head` and `n` arguments. @@ -45,19 +45,19 @@ Check if `ex` is an expression with head `head` and `n` arguments. julia> ex = :(f(x)) :(f(x)) -julia> isexpr(ex, :block) +julia> Meta.isexpr(ex, :block) false -julia> isexpr(ex, :call) +julia> Meta.isexpr(ex, :call) true -julia> isexpr(ex, [:block, :call]) # multiple possible heads +julia> Meta.isexpr(ex, [:block, :call]) # multiple possible heads true -julia> isexpr(ex, :call, 1) +julia> Meta.isexpr(ex, :call, 1) false -julia> isexpr(ex, :call, 2) +julia> Meta.isexpr(ex, :call, 2) true ``` """ @@ -66,13 +66,13 @@ isexpr(@nospecialize(ex), heads::Union{Set,Vector,Tuple}) = isa(ex, Expr) && in( isexpr(@nospecialize(ex), heads, n::Int) = isexpr(ex, heads) && length(ex.args) == n """ - show_sexpr([io::IO,], ex) + Meta.show_sexpr([io::IO,], ex) Show expression `ex` as a lisp style S-expression. # Examples ```jldoctest -julia> show_sexpr(:(f(x, g(y,z)))) +julia> Meta.show_sexpr(:(f(x, g(y,z)))) (:call, :f, :x, (:call, :g, :y, :z)) ``` """ diff --git a/doc/src/manual/metaprogramming.md b/doc/src/manual/metaprogramming.md index 8fdad8147c042..ae11362fafe2d 100644 --- a/doc/src/manual/metaprogramming.md +++ b/doc/src/manual/metaprogramming.md @@ -330,7 +330,7 @@ However, in some situations it is necessary to quote code *without* performing i This kind of quoting does not yet have syntax, but is represented internally as an object of type `QuoteNode`: ```jldoctest interp1 -julia> eval(quot(Expr(:$, :(1+2)))) +julia> eval(Meta.quot(Expr(:$, :(1+2)))) 3 julia> eval(QuoteNode(Expr(:$, :(1+2))))