Create QuoteNode in Expr


I’m trying to build this


as expression, so i can eval (it’s a longer story of library/code adaptation …)

julia> u1 = "ccall((:u3,\"./\"),Float64,(Float64,),x)"

julia> e0 = parse(u1)

julia> dump(e0)
  head: Symbol ccall
  args: Array{Any}((4,))
    1: Expr
      head: Symbol tuple
      args: Array{Any}((2,))
        1: QuoteNode
          value: Symbol u3
        2: String "./"
      typ: Any
    2: Symbol Float64
    3: Expr
      head: Symbol tuple
      args: Array{Any}((1,))
        1: Symbol Float64
      typ: Any
    4: Symbol x
  typ: Any

So how do i get the QuoteNode in the first argument to ccall?


Is this what you’re after:

julia> dump(:(:u3))
  value: Symbol u3


Not fully … i’d like to enter “u3” by string

julia> dump(:(:u3))
  value: Symbol u3

julia> dump(:(Symbol("u3")))
  head: Symbol call
  args: Array{Any}((2,))
    1: Symbol Symbol
    2: String "u3"
  typ: Any


Then this should work

julia> Core.QuoteNode(Symbol("u3"))



julia> function f1a()
           e1 = Expr(:tuple)
           e1.args = [Core.QuoteNode(Symbol("u3")), "./"]

           e2 = :Float64
           e3 = Expr(:tuple)
           e3.args = [:Float64]
           e4 = :x
           e5 = Expr(:ccall)
           e5.args = [e1,e2,e3,e4]
f1a (generic function with 1 method)

julia> e0 = f1a()

julia> x = 11.2

julia> eval(e0)

Core sound dangerously like ‘serious internal stuff’, is it recommended to use (and stay) or do i have better options constructing Expr?


I believe that you should use Meta.quot(Symbol("u3")) instead. See the discussion at


I tried this previously (according to my .julia_history) but somehow got it wrong, but it’s working now…