Personally, I think the real problem here is the fact that macros take optional 
parentheses. Your example seems like it should work, but it effectively was the 
same as doing:

@printf(("%d,%d\n", 1, 2))

I've started always using parentheses with macros because it helps to avoid 
some of these issues.

 -- John

On Jun 11, 2014, at 7:45 PM, J Luis <[email protected]> wrote:

> Hmm, if it has to be, it has to be but the error message is really misleading.
> 
> ... and BTW the manual example has a space
> 
> @name (expr1, expr2, ...)
> 
> Quinta-feira, 12 de Junho de 2014 3:26:39 UTC+1, Pontus Stenetorp escreveu:
> On 12 June 2014 11:06, J Luis <[email protected]> wrote: 
> > 
> > Hi, it took me a while and a good dose of swearing to figure this out 
> > 
> > julia> @printf ("%d,%d\n", 1,2) 
> > ERROR: @printf: first or second argument must be a format string 
> > 
> > julia> @printf("%d,%d\n", 1,2) 
> > 1,2 
> > 
> > The difference is only the space between the 'printf' and '(' 
> > Does it have to be like that? And can the error message be more correct? 
> 
> The issue is really with the way macros handle their arguments: 
> 
>     http://julia.readthedocs.org/en/latest/manual/metaprogramming/#macros 
> 
> This in combination with the fact that `one(Int)` and `one (Int)` are 
> equivalent, but `@printf("%d", 17)` and `@printf ("%d", 17)` are not. 
> From my own naive stand-point I would vouch for disallowing spaces 
> before the opening parenthesis for function calls a'la `one (Int)`. 
> This, in my opinion, is bad style anyway.  But perhaps I am missing 
> some case where it would be useful. 
> 
> Regards, 
>     Pontus Stenetorp 

Reply via email to