-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic Format Strings in Julia's @printf macro #29278
Comments
See also this old issue, #4248 |
Yes, I did see that, but hoped something changed in the last 5 years or so. It looks like this behavior is going to be baked into the language. |
Macros are evaluated at compile time, once a printf macro is compiled, the format string is fixed (and yes, that's baked into the language). If you need dynamic formatting goto https://github.com/JuliaIO/Formatting.jl or similar. |
@lobingera, in principle, the This would be backwards-compatible, so in principle it could be supported in 1.x. But it might mean folding something like Formatting.jl into the standard library. |
What is a bit puzzling is that |
This is now implemented in stdlib Printf: you can create |
julia> using Printf julia> fmt = "%10d" "%10d" julia> @printf(fmt, 123) ERROR: LoadError: ArgumentError: @printf: first or second argument must be a format string
It would be nice to have dynamic format strings for the @printf macro.
The text was updated successfully, but these errors were encountered: