On Friday, 23 January 2015 22:36:00 UTC-5, [email protected] wrote:
>
>
>
> On Saturday, January 24, 2015 at 1:13:55 PM UTC+10, Kirill Ignatiev wrote:
>>
>> I see nothing about this in 
>> http://julia.readthedocs.org/en/latest/manual/metaprogramming/#macro-invocation
>>
>> What's the logic behind reading macro arguments like this? Is it supposed 
>> to be this way? I found this syntax confusing.
>>
>
> Yes.
>
> 1,2,3 syntax creates a tuple as you found out, see 
> http://julia.readthedocs.org/en/latest/stdlib/punctuation/ the comma 
> isn't an argument separator for macros, only functions.  Its the lack of 
> commas for macro argument separation that allows syntax like "@parallel for 
> i=1:100000000".
>
> The arguments to macros are expressions.
>
> So the argument separator is whitespace *where it separates expressions*, 
> so spaces within the tuple list don't count since its a single expression.
>

I see, thank you. I originally tried to write somefun(@somemacro arg1, arg2)
 

> Cheers
> Lex
>
>>
>> julia> macro test(args...); @show args; args[1]; end
>>
>> julia> @test 1, 2, 3, 4
>> args = (:((1,2,3,4)),)
>> (1,2,3,4)
>>
>> julia> @test 1 2, 3, 4
>> args = (1,:((2,3,4)))
>> 1
>>
>> julia> @test 1 2 3 4
>> args = (1,2,3,4)
>> 1
>>
>> julia> @test 1, 2 3 4
>> args = (:((1,2)),3,4)
>> (1,2)
>>
>> julia> @test 1, 2 3, 4
>> args = (:((1,2)),:((3,4)))
>> (1,2)
>>
>>

Reply via email to