I’m all for using arbitrary expressions in interpolation as well - otherwise it’s closer to just “formatting” than proper “interpolation”. Of course, PyFormattedStrings.jl also support any julia syntax within strings.
Not completely sure what you mean by keyword arguments here, but I do see (from the docs) that Strs.jl is designed to be extensible.
“Normal strings” - that is, without the f-prefix? I personally don’t see the single-character prefix as any kind of inconvenience, just the opposite - it immediately tells the reader that there is some executable code within the string.
Well, I just convert the f-string to the corresponding printf format string, and then generate the same code as would be created by @sprintf
:
# format_str - the resulting printf format string
format = Printf.Format(format_str)
# arguments - list of interpolated expressions, in their occurrence order
return :(Printf.format($format, $(esc.(arguments)...)))
Using Printf
puts some limits on possible extensibility, but provides clear benefits in simplicity.