Interpolated strings

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 16 01:01:02 PDT 2017


On 2017-04-15 22:04, 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.

My initial reaction is that this is something that can be implemented as 
library code if the language would have support for AST macros.

On the other hand, this is something I would like to have in the 
language or the standard library.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list