The state of string interpolation

Dennis dkorpel at gmail.com
Thu Dec 6 22:52:28 UTC 2018


On Thursday, 6 December 2018 at 22:34:14 UTC, o wrote:
> Just think how much nicer this is (lowering to a string):
> `foo(i"My name is $name");`
>
> Compared to this (lowering to a tuple, requiring a conversion 
> to a string):
> ```
> import std.conv: text;
> foo(text(i"My name is $name"));
> ```

With UFCS it looks a lot nicer already:
```
foo(i"My name is $name".text);
```
How often do you actually need to pass an interpolated string to 
a function in string form? That's not a rethorical question, it 
is important to consider. If 90% of string interpolation happens 
in writeln / logging then it's not worth forcing the use of 
phobos + GC + eager toString and concatenation just to make the 
remaining 10% of cases a bit easier.


More information about the Digitalmars-d mailing list