I'm new to Julia, and got burned (aka wasted a fair amount of time)
trying to sort out why @sprintf didn't work as I expected.
julia> @sprintf("%2d",29)
"29"
julia> fmt = "%2d"
"%2d"
julia> @sprintf(fmt,29)
ERROR: @sprintf: first argument must be a format string
julia> @sprintf("%"*"2d",29)
ERROR: @sprintf: first argument must be a format string
I would expect that @sprintf would allow an arbitrary string expression as its
format string. It obviously doesn't...
There are many good reasons why one might want a format string expression instead
of just a constant format string. For example, the same format may be needed in
several places in the code, or you may want to compute the format string based on
certain item widths or other alignment needs.
At a minimum, this should (please!) be noted in the documentation.
Better would be to have the extended functionality...
(Or maybe it exists already -- have I missed something?)
Thanks!
Cheers,
Ron Rivest