Re:Implementing a Type-safe printf in Rust
by renox on Friday August 14, 2020 @09:54AM
(#24157955)
But both fail short to Python/bash.. format strings where you can have "in place" reference to variable which IMHO is much more readable.
[ Parent
| on HN ]
Re:Implementing a Type-safe printf in Rust
by ben-schaaf on Friday August 14, 2020 @10:31AM
(#24158406)
I completely agree that string interpolation is often superior to a format string, but it's important to note that they are not equivalent. String interpolation is generally evaluated in-situ and has full access to the local scope. Format strings on the other hand can be passed around and manipulated (even at compile-time) and can only ever access the data they're formatted with. strftime and strptime are a good example of a format string usage that can't be replaced by string interpolation in python.
D also has the capability of implementing string interpolation using mixins - though the resulting code isn't quite as neat.
Re:Implementing a Type-safe printf in Rust
by WalterBright on Friday August 14, 2020 @03:54PM
(#24162486)
I did write a proposal for "in place" reference (i.e. string interpolation) but could not reach consensus with the D community for it.
Re:Implementing a Type-safe printf in Rust
by CyberDildonics on Friday August 14, 2020 @01:16PM
(#24160539)
Formatting text output is not often a problem in the larger scope of a program, but having performance bottlenecks can be.