The state of string interpolation

Steven Schveighoffer schveiguy at
Thu Dec 6 20:57:07 UTC 2018

On 12/6/18 3:08 PM, Steven Schveighoffer wrote:
> On 12/6/18 2:52 PM, Adam D. Ruppe wrote:
>> Passing the actual variable as a CT arg is doable.. but only if there 
>> IS an actual variable.
>> i"hi $(name)"; // could pass T!("hi ", name)
>> i"hi $(a+b)"; // error: cannot read variables at compile time
> Yeah, I know. I was hoping we could bend the rules a bit in this case. 
> Since an interpolation would be a different kind of alias (with special 
> traits attached), it could have its own allowances that normally don't 
> happen. Make it like a lazy alias ;)

This doesn't work:

foo!(a + b);

But this does:

foo!(() => a + b);

However, the type is different, and it's not implicitly called, as it's 
a lambda.

So writeln(Args) would show "hi <someFunctionSignature>".

We still need some compiler-magic here, but it's almost supported...


More information about the Digitalmars-d mailing list