why @sprintf instead of sprintf?
1 Like
Now, it can count as a historical accident, like @evalpoly
.
From 1.6, there is Printf.Format
for format string and Printf.format
for producing strings or writing directly to the output.
1 Like
- “compile-time” vs. “run-time”
- And you can use it in the “code generation” part.
- like a code generation from a “template” but this is smarter
- Metaprogramming - Wikipedia
1 Like
Because then the parsing of the format string can be performed at compile time (with the resulting types known to the compiler), not runtime.
(You can also use Printf.format(Printf.format"...", args...)
to do compile-time parsing of the format string "..."
, but that’s a lot more cumbersome to write than @sprintf("...", args...)
.)
2 Likes