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

FeepingCreature feepingcreature at gmail.com
Mon Feb 8 11:46:03 UTC 2021

On Thursday, 4 February 2021 at 16:15:03 UTC, Meta wrote:
> However, if you want a tuple sequence as described in the DIP, 
> you can simply call a (probably compiler-supplied) helper 
> method; maybe it doesn't even have to be new: why not .tupleof?
> auto apples = 2;
> auto bananas = 3;
> auto s1 = i"I have ${apples + bananas} fruit";
> static assert(is(typeof(s1) == string));
> auto s2 = i"I have ${apples + bananas} fruit".tupleof;
> Then we can hide all the complexity of interpolated sequences 
> behind the .tupleof (or whatever we decide on) magic property.

IMO, if I pass an i"I have ${apples + bananas} fruit" to a 
function, and it allocates memory, this feature completely misses 
its purpose and I can't see where I'd use it. Right now, we're 
using a *lot* of format calls of the form `template 
function!"format string"(arguments), and the fact that these 
calls are high-performance and don't involve the GC is a massive 
argument in their favor. In extreme cases we can end up pushing 
megabytes of data every second through functions like this. 
Demanding tupleof for every such call is such an awkward syntax 
that I'd honestly rather not use the feature at all.

To me the tuple form is the primary usecase, not the string form. 
I understand that people think developers want something simple 
first and foremost, but if the complex form is the *only form I'd 
be interested in using*, then something's wrong.

More information about the Digitalmars-d mailing list