The state of string interpolation

Sjoerd Nijboer dlang at
Tue Dec 11 13:49:17 UTC 2018

On Monday, 10 December 2018 at 23:07:32 UTC, Paul Backus wrote:
> So maybe getting `interp` into Phobos is a better line of 
> attack than trying to sell W&A on new syntax.

I might be thinking something really silly, but since adding such 
a thing as string interpolation is pretty much (wanted) syntactic 
sugar, isn't it just possible to lower it? And if the answer to 
this is yes, why can't we have some much wanted syntactic library 
solutions as language features lowered in a compiler pass?
We can just maintain a separate set of lowerable language 
constructs into a combination of existing library functions 
instead of the true lowering of for loops and while loops and 
everything the like.
(we could lower a specific character before a string literal into 
a literal![STRING]; )
Isn't that more acceptable? Keeping syntactic sugar lowering 
separate from fundamental lowering? As far as I can see this 
would "promote" addition of syntactic sugar as a language feature 
because it can be maintained whitout a big impact on the language.
If certain syntactic sugar lowerings are deemed wanted, tested 
and found stable but can benefit from a performance increase by 
better compiler support using some other forms than just 
lowering, they might eventually be altered whitout impact to the 
Also, these syntactic sugar language features might be 
disabled/enabled by a compiler flag or dub setting.
All with all, I don't see how this couldn't realistically be 
included into the language like a lot of syntactic sugar. I 
understand the argument against it, but the potential benefits I 
can see are just too big to ignore.

More information about the Digitalmars-d mailing list