Discussion Thread: DIP 1036--Formatted String Tuple Literals--Community Review Round 1

Paul Backus snarwin at gmail.com
Sat Sep 12 15:13:15 UTC 2020


On Saturday, 12 September 2020 at 14:47:47 UTC, Andrei 
Alexandrescu wrote:
> On 9/12/20 9:44 AM, Paul Backus wrote:
>> // After
>> template Pack(Args...)
>> {
>>      alias expand = Args;
>> }
>
> Affirmative. We have that already: 
> https://dlang.org/library/std/typecons/tuple.expand.html
>
> A dead simple Pack would have a good place in druntime and have 
> Tuple be an elaboration thereof.

There's a version in std.meta, though it's currently marked as 
private:

https://github.com/dlang/phobos/blob/v2.093.1/std/meta.d#L1796

> I'd say don't complicate with that. Copy everything into the 
> tuple. When one reaches for interpolated strings, it's not like 
> they're hoping for a speed demon. Okay to draw the line at 
> @nogc.

It's not really about speed, it's about making sure that code 
that *looks* equivalent actually *is* equivalent. Do we want to 
have to explain to users that these two lines of code, which do 
the same thing:

    writeln(i"Hello $name!".expand);
    writeln("Hello ", name, "!");

...actually have subtly different evaluation semantics, and that 
very occasionally they may have to stop think about whether they 
want the first or the second one?

This is the same kind of situation as C++ is in w.r.t. 
initialization, which has been described as a "nightmare". [1] 
Obviously the scale of the issue here is much smaller, but even 
small annoyances can add up over time.

[1] https://www.youtube.com/watch?v=7DTlWPgX6zs


More information about the Digitalmars-d mailing list