DIP 1027--String Interpolation--Final Review Discussion Thread

Walter Bright newshound2 at digitalmars.com
Wed Feb 5 05:26:30 UTC 2020


On 2/4/2020 1:59 PM, Steven Schveighoffer wrote:
> On 2/4/20 2:12 AM, Walter Bright wrote:
>> On 2/3/2020 5:06 PM, Jonathan Marler wrote:
>>> Some applications want the "Strings and Expressions" form rather than the 
>>> "Format String" form.
>>
>> To have "strings and expressions" then write it that way:
>>
>>      foo("I want ", i, " bananas");
> 
> To have "formatted string output", just write it that way:
> 
> writefln("I have %s apples and %d bananas", apples, bananas);

The reason for formatted strings is for formatting that is other than the 
default, and to interface with common functions that use formatted strings.

Strings and expressions are stuck with the default format. If you're happy with 
the default formatting,

     writefln("I want $i bananas");

is not much of any improvement over:

     writeln("I want ",i," bananas");



More information about the Digitalmars-d mailing list