DIP 1027---String Interpolation---Community Review Round 1

Timon Gehr timon.gehr at gmx.ch
Fri Dec 13 02:10:04 UTC 2019


On 13.12.19 02:30, Adam D. Ruppe wrote:
> On Friday, 13 December 2019 at 01:19:32 UTC, mipri wrote:
>> This doesn't work though:
>>
>>   auto n = 4;
>>   [1,2,3].map!(format("a + %s", n)).each!writeln;
> 
> Indeed, but it does work to pass seq!(() => n). That's why I've amended 
> my proposal to do that instead. Then it inherits the CT-ness of n while 
> still being usable in a runtime context.
> 
> It is similar to `lazy` parameters built into the language;

I think that's a bit hacky, e.g.:

int x=0;
auto s=i"$(++x)";
writeln(s); // 1
writeln(s); // 2


More information about the Digitalmars-d mailing list