On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
Hi all
I've been wanting to have support for interpolated strings in
D for some time now that will allow you to write e.g.:
auto a = 7;
writeln( $"{a} times 3 is {a*3}" );
Code speaks louder that words so I've made a PR that adds this
support to ddmd as a RFC [1].
The compiler will basically lower the $"..." string to a mixin
that concatenates
the expression parts of the (inside the {}) and the plain text
parts.
I do recognize that this is not part of the 2017 H1 plan but I
also believe such smaller improvements added regularly can make
the language both more productive and attractive.
In case this addition gets a thumbs up I will of course improve
test coverage and any needed quality of implementation.
[1] https://github.com/dlang/dmd/pull/6703
This has been proposed before, and I still don't see the added
value compared to:
auto a=7;
writeln(a, " times 3 is ", a*3);
besides adding compiler complexity, language complexity and
parsing complexity which leaves room for more bugs to be
invented. I'm a bit more harsh than I could be, but if this
simple question has no clear answer I don't see why it sould make
it into the language.