Thanks for that, i know i've seen that :kw before.
Much appreciated.
Bassem


On Fri, Feb 21, 2014 at 3:25 PM, Simon Kornblith <[email protected]>wrote:

> As you have surmised, the b=5 kw argument is not actually the same as
> :(b=5) (you can see this using xdump(ex.args)). Instead of :(b=7), use  
> Expr(:kw,
> :b, 7).
>
> On Friday, February 21, 2014 6:17:48 PM UTC-5, Bassem Youssef wrote:
>>
>> Suppose i have a simple function as follows:
>>
>> julia> func(a;b=3) = a + b
>> func (generic function with 1 method)
>>
>> as expected:
>> julia> func(3,b=5)
>> 8
>>
>> julia> ex = :(func(3,b=5))
>> :(func(3,b=5))
>>
>> julia> eval(ex)
>> 8
>>
>> julia> ex.args
>> 3-element Array{Any,1}:
>>   :func
>>  3
>>   :(b=5)
>>
>> julia> ex.args[3]
>> :(b=5)
>>
>> However, this doesn't work:
>> julia> ex.args[3] = :(b=7)
>> :(b = 7)
>>
>> Notice, the extra spacing between b,= and 7
>> julia> ex.args
>> 3-element Array{Any,1}:
>>   :func
>>  3
>>   :(b = 7)
>>
>> now this doesn't work:
>> julia> eval(ex)
>> ERROR: no method func(Int64, Int64)
>>
>> regards,
>> Bassem
>>
>>
>>
>

Reply via email to