Hacker News new | past | comments | ask | show | jobs | submit login

But both fail short to Python/bash.. format strings where you can have "in place" reference to variable which IMHO is much more readable.



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.


I did write a proposal for "in place" reference (i.e. string interpolation) but could not reach consensus with the D community for it.


Formatting text output is not often a problem in the larger scope of a program, but having performance bottlenecks can be.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: