I'm not an expert, nor do I understand what you're trying to do.

Presumably you've read: 
http://docs.julialang.org/en/release-0.4/manual/metaprogramming/


I'm also somewhat confused by various ways to create expressions, and their 
relationship to each other:

:(code)

quote
   code
end

Expr(:quote, :(code))


Note that dump() is sometimes useful.

e1 = :(a+1)
e2 = quote a+1 end
e3 = Expr(:quote, :(a+1))

dump(e1)
dump(e2)
dump(e3)

e2.args[2] == e1
e3.args[1] == e1


$ is interpolation within an expression, so that :($expr) == expr
:($e1) == e1 == :(a+1)


Finally, if you quote a symbol you'll get a QuoteNode:

julia> z = :(:a)
:(:a)

julia> dump(z)
QuoteNode
  value: Symbol a

julia> z.value
:a


If you quote an expression, you'll get a Quote expression:

z = :(:(a+1))
dump(z)
z == e3



On Saturday, April 2, 2016 at 11:52:42 AM UTC+11, vis...@stanford.edu wrote:

> > x = :(:x)
> > $x
>
> *ERROR: unsupported or misplaced expression $*
>
>
> Is there a quote/unquote function that mimics the behavior or what happens 
> when you wrap something with :() or do $x? I want to retrieve what's inside 
> the variable x's expression.
>
> It's not sufficient to just wrap in Expr(:quote, ...) since that's not the 
> same as :() and similarly I can't find any documentation on how to unquote 
> something.
>
> There must be some routine being called in order to do the 
> quoting/unquoting - is there a way to access it?
>
>
> Vishesh
>

Reply via email to