Expr(:quote, x) == Meta.quot(x)

(and Meta exports quot, so you can use `using Meta` to bring that in and 
use it as `quot(x)`)

On Wednesday, February 12, 2014 12:06:38 AM UTC-6, Fil Mackay wrote:
>
> Thanks Jake, the final answer for completeness (using the symbol name from 
> a string) was:
>
> :(f($(Expr(:quote, symbol(:($name))))))
>
> eval()s to:
> :(f(:abc))
>
> On Wed, Feb 12, 2014 at 4:38 PM, Jake Bolewski 
> <[email protected]<javascript:>
> > wrote:
>
>> Hey Fil,
>>
>> More directly answering your question:
>>
>> julia> eval(:(f($:(:abc))))
>>
>> or eqivalently
>>
>> julia> eval(:(f($(Expr(:quote, :abc)))))
>>
>> works.
>>
>> Best,
>> Jake
>>
>>
>> On Wednesday, February 12, 2014 12:30:13 AM UTC-5, Jake Bolewski wrote:
>>>
>>> you need to take advantage of quote, see:
>>> https://groups.google.com/forum/#!topic/julia-dev/YxTEkUJcwL8
>>>
>>> Jake 
>>>
>>> On Tuesday, February 11, 2014 11:57:16 PM UTC-5, Fil Mackay wrote:
>>>>
>>>> Is there not an ambiguity of operator : between expressions and 
>>>> symbols? I am trying to create an expression that calls a function with a 
>>>> symbol parameter, that comes from a string in context of the expression 
>>>> creator:
>>>>
>>>> function f(s::Symbol)
>>>> end
>>>>
>>>> f(:abc) # works
>>>>
>>>> # get symbol name from a string
>>>> name = "abc"
>>>> f(symbol(name)) # works
>>>> eval(:(f(symbol(name)))) # still works
>>>>
>>>> # moving over to using the context of the expression creator to specify 
>>>> the symbol:
>>>> eval(:(f($(symbol("abc"))))) # nope, this generates: f(abc)
>>>> eval(:(f(:(:($(symbol("abc"))))))) # bad, generates: f(Expr)
>>>>
>>>> # workaround:
>>>> eval(:(f(:($(symbol("abc")))))) # almost, but generates: 
>>>> f(symbol("abc")) not f(:abc)
>>>>
>>>> Is there a trick to generate a more direct expression that eval() to: 
>>>> f(:abc) ?
>>>>
>>>>
>

Reply via email to