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

Adam D. Ruppe destructionator at gmail.com
Sat Sep 12 02:48:38 UTC 2020

On Friday, 11 September 2020 at 20:46:05 UTC, Paul Backus wrote:
> This solves the issue of accidentally passing the wrong thing 
> with i"Window $id", and also prevents non-interpolation-related 
> accidental usage, like mixing up the width and height.

yeah that's legit.

So what we're considering is simplifying it a bit and dropping 
the embeddable format strings. Also Steven is seeing if he can 
make auto-conversion work and I'm mulling over your idea of two 
different prefixes. t"..." yields the tuple, i"..." automatically 
calls idup (or whatever). t is the building block, i is the "just 
give me a string" shortcut built on top of t.

So in my next draft, processing a t"" yourself looks like:

auto foo(InterpList, Args...)(InterpList interp, Args args) {
     string ret;
     foreach(idx, arg; args) {
         ret ~= interp.strings[idx];
         ret ~= to!string(arg);
     ret ~= interp.strings[args.length];
     return ret;

And processing an i"" is trivial; it is just either a string or a 
subclass of string (aka a struct with alias toString this) and 
you'd just use it like that.

The t"" is more composable; it is the superior language feature. 
But I can live with a convenience compromise.

So we'll see.

More information about the Digitalmars-d mailing list