The state of string interpolation

Jonathan Marler johnnymarler at gmail.com
Fri Dec 7 14:40:05 UTC 2018


On Friday, 7 December 2018 at 07:53:14 UTC, Mike Franklin wrote:
> On Friday, 7 December 2018 at 01:47:13 UTC, H. S. Teoh wrote:
>
>> And yes, `mixin interp!"..."` is horribly verbose. But 
>> ostensibly we could abbreviate it to something like `mixin 
>> i!"..."`.
>
> Perhaps what's needed is a different mixin operator that is not 
> verbose and significantly distinguishes it from the template 
> instantiation operator.
>
> mixin i!"...";  // instead of this...  (too verbose)
> i!"...";        // or this... (looks too much like a template 
> instantiation)
> i#"...";        // we create a new mixin operator `#`
>
> Mike

An interesting idea.

Maybe id#(...) lowers to mixin(id(...)) Or something.

Keep in mind though, that interpolated strings implemented using 
this will have the disadvantages of mixin code, bad error 
messages, hard to debug and a hit to compile time performance. 
Plus you still need the extra import. Even if we could implement 
interoplated strings this way, it may still be worth it to add 
the small amount of code to the compiler for the extra benefits. 
But this idea is the first I heard that could work.


More information about the Digitalmars-d mailing list