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

Daniel N no at public.email
Thu Feb 4 16:33:22 UTC 2021


On Thursday, 4 February 2021 at 13:44:48 UTC, Adam D. Ruppe wrote:
> On Thursday, 4 February 2021 at 07:09:07 UTC, Daniel N wrote:
>> With a plain tuple it is possible to create a wrapper which 
>> generates DIP1036 style lowering (or simply work directly in 
>> the template with the value params).
>
> That forces CTFE evaluation of *everything* which is pretty 
> useless.
>
> int bar;
> fun!(i"foo {$bar+5}"); // bar cannot be evaluated at compile 
> time
>

Expressions could simply be lowered to temporaries on demand...

fun!(i"foo ${bar+5}");
======================
(int __expr0) {
   return fun!("foo ", __expr0);
}(bar+5);

Which works perfectly fine, it does archive my goal of reducing 
the complexity in the *common case*.

Arguably it's even more complex in the case where the lambda is 
needed, so I can understand if not everyone is happy with my 
idea... but if it was my proposal I wouldn't even support 
expressions, plain "$bar" is the sweet spot, no need for ${}, nor 
temporaries, keep it simple.

Well, maybe you are right about template instance bloat being 
exaggerated, I didn't benchmark it recently.

/Daniel N



More information about the Digitalmars-d mailing list