String Interpolation

bachmeier no at spam.net
Thu Oct 26 16:14:08 UTC 2023


On Thursday, 26 October 2023 at 15:45:48 UTC, jmh530 wrote:

> For reference, both Adam and Walter's versions show how it is 
> possible with `.text` or `.format`.
>
> https://github.com/dlang/dmd/pull/15722#issuecomment-1774153328
> https://github.com/adamdruppe/interpolation-examples/blob/e275f110898758dbbbfaa5427a72c9a18387d065/01-basics.d#L13C25-L13C78
>
> I'm sympathetic to not putting that functionality in the 
> compiler.

I'd agree if the only thing I cared about is good language design 
and didn't care at all about usability. Why not this?

```
import std.format;
string s = $"Hello, ${world}";
```

Anyone that wants what's currently on offer could still do this 
if they want:

```
string s = i"Hello, ${world}".format;
```


More information about the Digitalmars-d mailing list