DIP 1027---String Interpolation---Community Review Round 1

Ernesto Castellotti erny.castell at gmail.com
Thu Dec 12 07:03:16 UTC 2019


On Wednesday, 11 December 2019 at 17:49:45 UTC, Meta wrote:
> On Wednesday, 11 December 2019 at 15:55:35 UTC, Patrick 
> Schluter wrote:
>> On Wednesday, 11 December 2019 at 12:50:34 UTC, Ernesto 
>> Castellotti wrote:
>>> On Wednesday, 11 December 2019 at 09:52:21 UTC, Mike Parker 
>>> wrote:
>>>> [...]
>>>
>>> From the dip it seems that it is only valid for writefln & co
>>> So a code like:
>>>    auto myText = i"I ate% apples"
>>> would not be valid.
>>
>> It is allowed everywhere where a tuple expression is allowed
>>
>> auto myText = "I ate%s", apples
>>
>> doesn't make sense
>
> It works already (un?)fortunately:
>
>     auto test = AliasSeq!("The product of %s and %s is %s", 2, 
> 5, 10);
>     writeln(test);  //Prints "The product of %s and %s is 
> %s2510"
>     writefln(test); //Print   "The product of 2 and 5 is 10"
>
> This DIP is just taking that 1 extra small step to allow i"" 
> strings to be lowered to tuple literals.

Yes this is the purpose of the dip, but it is not what I expect 
for the string interpolation.
This would require explicitly calling the functions of a library 
to convert the tuple into a string, I would like it to be done
literals implicitly.



More information about the Digitalmars-d mailing list