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

aliak something at something.com
Thu Feb 27 11:44:59 UTC 2020


On Thursday, 27 February 2020 at 09:34:23 UTC, Walter Bright 
wrote:
> On 2/26/2020 7:41 AM, Arine wrote:
>> Yah, what's unwanted about that?
>
> 1. unwanted extra string allocation
> 2. poor performance
> 3. doesn't work with printf
> 4. doesn't work with writef
> 5. non-default formats require extra temp strings to be 
> generated

Pretty sure he meant that this call:

int a;
CreateWindow(i"Title $a");

Would call CreateWindow like:

CreateWindow("Title %s", a);

Which is what is unwanted.

Btw: with the adam-steve-twist you fix everything that is 
unwanted, including enforcing explicitness when someone wants it 
to act as a string, without the danger of mistakenly calling the 
wrong overloads of functions because of switching to string 
interpolation.

And it seems to me there's precedent in typeid

i.e. typeid is an construct in D that lowers to a TypeInfo type, 
which is defined somewhere (is that object.d?) Anyway. The same 
would happen with the interpolated string.

Btw: Swift does this for string interpolation and it works very 
well -> 
https://www.hackingwithswift.com/articles/178/super-powered-string-interpolation-in-swift-5-0


More information about the Digitalmars-d-announce mailing list