# Create QuoteNode in Expr

**URL:** <https://discourse.julialang.org/t/create-quotenode-in-expr/1319>\
**Category:** General Usage\
**Created:** [January 6, 2017, 8:26am UTC](https://discourse.julialang.org/t/create-quotenode-in-expr/1319 "2017-01-06T08:26:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 6, 2017, 8:26am UTC](https://discourse.julialang.org/t/create-quotenode-in-expr/1319/1 "2017-01-06T08:26:19Z")

</div>

I’m trying to build this

```julia

ccall((:u3,"./u1.so"),Float64,(Float64,),x)

```

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

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

julia> e0 = parse(u1)
:(ccall((:u3,"./u1.so"),Float64,(Float64,),x))

julia> dump(e0)
Expr
  head: Symbol ccall
  args: Array{Any}((4,))
    1: Expr
      head: Symbol tuple
      args: Array{Any}((2,))
        1: QuoteNode
          value: Symbol u3
        2: String "./u1.so"
      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?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [January 6, 2017, 8:33am UTC](https://discourse.julialang.org/t/create-quotenode-in-expr/1319/2 "2017-01-06T08:33:11Z")

</div>

Is this what you’re after:

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

```

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 6, 2017, 8:44am UTC](https://discourse.julialang.org/t/create-quotenode-in-expr/1319/3 "2017-01-06T08:44:22Z")

</div>

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

```julia

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

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

```

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [January 6, 2017, 8:48am UTC](https://discourse.julialang.org/t/create-quotenode-in-expr/1319/4 "2017-01-06T08:48:14Z")

</div>

Then this should work

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

```

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 6, 2017, 8:55am UTC](https://discourse.julialang.org/t/create-quotenode-in-expr/1319/5 "2017-01-06T08:55:45Z")

</div>

Yes.

```julia

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

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

julia> e0 = f1a()
:(ccall((:u3,"./u1.so"),Float64,(Float64,),x))

julia> x = 11.2
11.2

julia> eval(e0)
13.2

```

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

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 6, 2017, 9:10am UTC](https://discourse.julialang.org/t/create-quotenode-in-expr/1319/6 "2017-01-06T09:10:26Z")

</div>

> [@lobingera](#):
>
> 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

> <https://github.com/JuliaLang/julia/issues/6104>
>
> There now seem to be three ways of generating quoted symbols for the AST. Howeve…r, print\_unquoted doesn't seem to know about Expr(:quote). But on the whole, what is the difference between them, and can we deprecated \`Meta.quot\` and \`Expr(:quote)\`?

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [January 6, 2017, 9:22am UTC](https://discourse.julialang.org/t/create-quotenode-in-expr/1319/7 "2017-01-06T09:22:46Z")

</div>

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