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

Walter Bright newshound2 at digitalmars.com
Sat Dec 14 21:22:41 UTC 2019


On 12/14/2019 7:07 AM, Steven Schveighoffer wrote:
> On 12/14/19 2:34 AM, Walter Bright wrote:
>> On 12/11/2019 2:57 AM, Alexandru Ermicioi wrote:
>>> Why not just split interpolated string into just a tuple of args & strings. 
>>> For example:
>>> Given: (i"I ate %apples and %bananas totalling %(apples + bananas) fruit.")
>>> Is lowered to a tuple: ("I ate ", apples, " and ", bananas," totalling ", 
>>> apples + bananas," fruit.")
>>
>> I don't see the point of that. The user could write it that way to begin with.
> 
> Walter, this is literally the point of string interpolation. A similar response 
> to your entire proposal could be, why not just use writeln and write out all the 
> items?

String interpolation for format strings is quite different.


> The point is not just to put the expressions where they belong, but to be less 
> verbose about it. The dance of quotes and commas is hard to read and hard to write.

     "I ate ",
      apples,
     " and ",
      bananas,
     " totalling ",
      apples + bananas,
     " fruit."

isn't too bad. Formatting, though, won't change the issue with format strings 
and the disconnect between the arguments and their positions.



More information about the Digitalmars-d mailing list