Dear all,

For me personally my biggest irritation with Julia is the fact that 
@sprintf() is a macro and not a function. That means that I am always 
forced to write the entire format string in one go. For example, this 
doesn't work:

julia> fmt = "%3d"
"%3d"

julia> @sprintf(fmt,a)
ERROR: @sprintf: first argument must be a format string


If the format string is long, or if I want to generate it dynamically, this 
quickly becomes cumbersome and irritating. I would much rather have a 
traditional printf() and sprintf() function that I can use naturally:

fmt = "%15s - " * repeat("  %7.4f", 17)

printf(fmt * "\n", name, vals...)


Yes, it is possible to work around this seemingly arbitrary limitation, but 
that goes against the spirit of writing code that is clear and simple. I 
generally like Julia because the code is clear with very little extraneous 
syntax, so the implementation of @sprintf sticks out like a sore thumb.

Is there any hope that this might change some day? I really don't 
understand why we have to use a macro here. Even C/C++ can manage to have a 
printf function. Why can't Julia?


Cheers,
Daniel.

Reply via email to