Interpolated strings

Nick Sabalausky (Abscissa) via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 16 09:10:15 PDT 2017


On 04/15/2017 04:35 PM, crimaniak wrote:
> On Saturday, 15 April 2017 at 20:04:13 UTC, Jonas Drewsen wrote:
>> The compiler will basically lower the $"..." string to a mixin that
>> concatenates
>> the expression parts of the (inside the {}) and the plain text parts.
> It's easy implementable as a library (see
> https://github.com/Abscissa/scriptlike#string-interpolation) so it does
> not seem like a good idea to modify the language, only to change
> interp!"" to $"".

Yea, and note, I'm still open to the idea of better names than "interp". 
I'm still not entirely happy with that name. I'm even half-tempted to 
use "_".

The only one problem I've found with doing it in library though: Far as 
I could tell, it seems to require the caller uses string mixins, which 
makes actually using it a little uglier and more verbose than I would 
like. Maybe I'm overlooking something obvious, but I haven't been able 
to find a way to change it to either a template mixin or even just a 
plain template without sacrificing to whole point of interpolated 
strings: specifying the arguments 100% inline.

What I think would be ideal is a language enhancement to allow "interp" 
to do its job without the extra syntactical noise. That would not only 
give us good interpolates strings, but would likely have other 
applications as well.



More information about the Digitalmars-d mailing list