String Interpolation
Walter Bright
newshound2 at digitalmars.com
Sat Oct 21 17:10:58 UTC 2023
On 10/21/2023 5:38 AM, Commander Zot wrote:
> can we please just have ```i"whatever ${var}"``` to return a fully interpolated
> string, not a tuple, not a template or anything.
> because the common use case is ```auto s = i"whatever ${var}";```,
> so maybe just lower it into ```format("whatever %s", var)```.
Better tuple support is in the cards for D. They should be pretty straightforward.
For DIP1027,
```
int var = 67;
auto s = format(i"whatever $var");
```
would be equivalent to:
```
auto s = "whatever 67";
```
I.e. there are two steps involved:
1. convert the istring to a tuple
2. convert the tuple to a string
Having them be two steps enables the user to insert step 2:
1. convert the istring to a tuple
2. modify the tuple
3. convert the tuple to a string
More information about the Digitalmars-d
mailing list