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

Steven Schveighoffer schveiguy at gmail.com
Fri Jan 29 17:01:36 UTC 2021


On 1/29/21 10:49 AM, Paul Backus wrote:
> On Friday, 29 January 2021 at 15:28:21 UTC, Steven Schveighoffer wrote:
>>
>> The intent is for the compiler to identify the exact location of interp.
>>
>> This doesn't necessarily mean lowering, it means that only the 
>> druntime interp template will be used (which is easy to do internally).
> 
> Once the `interp` instance passes through the implicit .stringof in 
> mixin(...), all of that semantic information is lost. Most of the time 
> you will get lucky and it will work anyway, but you have no guarantee.

mixin(i"int ${idname} = 5;"); will ALWAYS be rewritten to 
mixin(idup(i"int ${idname} = 5;"));

If that is not clear in the DIP, it will be in the next update.

> Adam knows all about the pitfalls of mixin + stringof, so feel free to 
> ask him about it if you still don't understand.

I understand and it's not relevant.

>> There will be no overriding of interp or idup allowed in user code. I 
>> could have sworn I had a statement in the DIP that said that, but I 
>> may have deleted it in the many rewrites.
> 
> Unless you make `interp` and `idup` reserved identifiers (which is a 
> breaking language change), there is no way you can prevent this in the 
> general case.

The compiler is building the instantiation of interp and idup, it can do 
whatever it wants to tell itself what it should do. The idea that they 
would need to be reserved identifiers is irrelevant, they don't appear 
in code. In fact, they can be __interp and __idup if you want, it 
doesn't really matter what they are called.

It is true that an explicit idup call will have to deal with any local 
overrides. But that is true for idup in general.

-Steve


More information about the Digitalmars-d mailing list