Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2

Paul Backus snarwin at gmail.com
Thu Feb 4 17:05:30 UTC 2021

On Thursday, 4 February 2021 at 17:00:43 UTC, Ola Fosheim Grøstad 
> On Thursday, 4 February 2021 at 15:34:07 UTC, Adam D. Ruppe 
> wrote:
>> but you don't know that the opening brace is interpolating.
>> enum name = "foo";
>> mixin(iq{ void {name}() {bar} });
>> Is {bar} interpolation or a function body?
> It would be interpolation. If you are in text (string) mode 
> when hitting "{" it would be taken as opening an expression 
> that should be converted to string. So, no ambiguity.

This makes using interpolation to generate D code significantly 
more cumbersome, because '{' is a common character in D code, and 
every occurrence of it would have to be escaped. It is much 
easier if the sequence used to introduce an interpolated 
expression is not a valid D token.

More information about the Digitalmars-d mailing list