Better string mixins

Dgame r.schuett.1987 at gmail.com
Wed Jan 2 21:57:07 UTC 2019


On Wednesday, 2 January 2019 at 21:52:06 UTC, Jordan Wilson wrote:
> On Wednesday, 2 January 2019 at 21:06:19 UTC, Bastiaan Veelo 
> wrote:
>> On Wednesday, 2 January 2019 at 18:59:53 UTC, Dgame wrote:
>>> Hi, I've played around with string interpolation and wanted 
>>> to ask if this is somewhat helpful?
>>>
>>> https://run.dlang.io/is/6AokiH
>>
>> You are aware of `writefln`?
>>
>>>    writeln(fmt!("a = $a, b = $b, c = $c", a, b, c));
>>>    writefln("a = %s, b = %s, c = %s", a, b, c);
>>
>> These lines produce the same output.
>
> This also produces the same output:
> writeln(fmt!("a = $a, b = $b, c = $c", c, a, b));
>
> From what I can see, fmt removes the positional relationship 
> between the vars and the format  specifiers, but you still have 
> to supply the actual variables themselves as arguments, which 
> is a redundancy that string interpolation in some other 
> languages don't appear to have.
>
> Jordan

That is correct, I might have been a bit hasty in sharing my 
little experiment.


More information about the Digitalmars-d mailing list