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

Paul Backus snarwin at gmail.com
Fri Jan 29 14:21:39 UTC 2021


On Friday, 29 January 2021 at 14:17:41 UTC, Dukc wrote:
> On Friday, 29 January 2021 at 13:21:18 UTC, Paul Backus wrote:
>> In concrete terms, what happens is that mixin implicitly calls 
>> `.stringof` on each of its arguments. So your mixin example 
>> would be lowered to
>>
>>     mixin(interp!"foreach(i;0.."().stringof, 
>> iterations.stringof, interp!") foo();"().stringof);
>>
>> And evaluating the `.stringof` calls would result in
>>
>>     // assuming iterations == 5
>>     mixin(`interp()`, `5`, `interp()`);
>
> Oops. I quess the DIP would do well to solve that somehow.
>
>>
>> ...which in this specific case happens to be a compile error, 
>> so it actually *would* be rewritten by the compiler to use 
>> `idup`..
>
> Or perhaps not, since the compiler error would not result from 
> arguments not being accepted.

...unless you happen to have something else named `interp` in 
scope that makes the `.stringof` results compile. Have fun 
chasing down *that* bug. :)


More information about the Digitalmars-d mailing list