DIP 1027---String Interpolation---Format Assessment

FeepingCreature feepingcreature at gmail.com
Wed Feb 26 12:18:07 UTC 2020


On Wednesday, 26 February 2020 at 11:13:12 UTC, Petar Kirov 
[ZombineDev] wrote:
> On Wednesday, 26 February 2020 at 09:45:55 UTC, Walter Bright 
> wrote:
>> It is lowered to:
>>
>>   f("hello %s", a);
>>
>> as designed. I don't know what's unwanted about it.
>
> In all other languages with string interpolation that I'm 
> familiar with, `a` is not passed to the `i` parameter.
>
> ---
> [snip]

To be fair, none of those languages care about an extra string 
allocation.

But to be fair again, Adam/Steven's proposal can avoid the memory 
allocation while also not passing i implicitly, at the cost of 
not matching to the string type.

But to be thrice fair, Adam/Steven's proposal would work with the 
minor extension `f(i"hello $a".format)`/`f(i"hello 
$a".to!string)`, in keeping with the trend of GC use requiring 
explicit opt-in.


More information about the Digitalmars-d-announce mailing list