News for hackers. Stuff that matters.
Re:ECMAScript 6 looks promising by Tichy on Thursday November 24, 2011 @11:54AM (#3274798)
Somehow you have to get those values into the String, though. How do you propose doing it? Seems to me you can either concatenate Strings ("hello "+name) or interpolate ("hello #{name}")? Interpolating actually looks cleaner to me.

Or of course create_string("hello $1", name) or something like that.

Re:ECMAScript 6 looks promising by masklinn on Thursday November 24, 2011 @12:42PM (#3274928)
> Interpolating actually looks cleaner to me.

Definitely. It can't be used for i18n though, which is problematic (interpolation usually uses full expressions, so it's essentially a vector of code injection).

> Or of course create_string("hello $1", name) or something like that.

There are already string formatting minilanguages, no need to make up your own: you can use printf's format or C#-style string formats (I think the C# one is rather nice, especially its extensions in Python which allow for implicit positional and named formatting)