DIP 1027--String Interpolation--Final Review Discussion Thread
Steven Schveighoffer
schveiguy at gmail.com
Wed Feb 5 14:24:57 UTC 2020
On 2/5/20 4:15 AM, Johannes Loher wrote:
> On Wednesday, 5 February 2020 at 06:48:43 UTC, Arine wrote:
>>
>> string v = i"value = $value";
>>
>> A user isn't going to expect that to be:
>>
>> string v = ("value = %s", value);
>
> This still boggles my mind. I know that you can simply write
>
> string v = i"value = $value".format;
>
> instead but this is not what anybody who already knows about string
> interpolation from any other language will expect. It is really weird to
> have a string syntax (i"") where the result of such an expression is not
> actually a string (or at the very least implicitly convertible to one).
>
> Do we really want D to be the odd one out in this case?
I suggested in the first review round [1] that we don't call this
"string interpolation" to avoid this confusion (because everyone will
just expect this).
But I absolutely think that this is how D should support string
interpolation. It's just so much more beneficial than translating to an
automatic call to format (note that this WOULD require a library to do
it, as the compiler can't possibly know how to string-ify all parameters).
-Steve
[1] https://forum.dlang.org/post/qt8ust$26if$1@digitalmars.com
More information about the Digitalmars-d
mailing list