I like sprintf1() as a dynamy/performance compromise for @printf, but it's not a drop-in replacement.
When working in a print-ecosystem, you end up doing things like print(io,sprintf(frmt,x)), which unnecessarily generates a string.
I don't know the best way to implement a fprintf1 function without reusing a lot of code, but from what I've seen the most common way to do this kind of thing is to have fprintf be the base function, have sprintf use fprintf on an IOBuffer to generate the string.
I like
sprintf1()
as a dynamy/performance compromise for@printf
, but it's not a drop-in replacement.When working in a print-ecosystem, you end up doing things like
print(io,sprintf(frmt,x))
, which unnecessarily generates a string. I don't know the best way to implement afprintf1
function without reusing a lot of code, but from what I've seen the most common way to do this kind of thing is to havefprintf
be the base function, havesprintf
usefprintf
on anIOBuffer
to generate the string.Is there a strong reason to not do this?