String interpolation, after a healthy debate on discord
Ogi
ogion.art at gmail.com
Tue Dec 14 12:41:27 UTC 2021
On Tuesday, 14 December 2021 at 11:15:02 UTC, WebFreak001 wrote:
> ah right you mean for the built-in istring usage in the
> compiler it needs to be implemented.
>
> I don't think it's such a big problem though, as the phobos
> implementation would also just be: (a little simplified)
>
> ```d
> auto text(istring...)(istring s) if (isIString!istring)
> {
> return text(s[1 .. $]); // removes special __header, just
> concatenate rest
> }
> ```
My point is, if the compiler has to implement istring processor
anyway, why not make it a language feature:
```D
//look ma no imports
int bottleCount = 99;
string str = i"$(bottleCount) bottles on the wall".stringof;
assert(str == "99 bottles on the wall");
More information about the Digitalmars-d
mailing list