String Interpolation
Arafel
er.krali at gmail.com
Sun Oct 22 11:32:12 UTC 2023
On 21/10/23 19:10, Walter Bright wrote:
> For DIP1027,
>
> |int var = 67; auto s = format(i"whatever $var"); |
>
> would be equivalent to:
>
> |auto s = "whatever 67";|
At which point it's barely an improvement overs what we can already do:
```
int var = 67; auto s = mixin(i!"whatever $var");
```
I'm not saving even one keypress, and readability isn't that much better
either.
And we'll end up with multiple string literals, like `r"` and `q"`, and
then something called "interpolated string" that uses a very similar
token `i"` but that can't be used as a string, not even in the most
straightforward cases.
Don't you think this will be unnecessarily confusing for users?
That's why I prefer DIP1036 over DIP1027, or even YAIDIP.
I understand that you don't want to make it implicitly convertible to
strings. Fair enough, I'm sure there are solid reasons for that. But
please, in that case, don't call it a "string", and also don't give it a
string-like syntax.
Perhaps "interpolated sequence" with a clearly differentiated syntax?
That would describe the feature much better.
More information about the Digitalmars-d
mailing list