DIP 1027---String Interpolation---Format Assessment
aliak
something at something.com
Wed Feb 26 10:33:03 UTC 2020
On Wednesday, 26 February 2020 at 09:45:55 UTC, Walter Bright
wrote:
> On 2/25/2020 1:36 AM, aliak wrote:
>> This may have already been answered in the other threads, but
>> I was just wondering if anyone managed to propose a way to
>> avoid this scenario with DIP1027?
>>
>> void f(string s, int i = 0);
>> f(i"hello $a"); // silent unwanted bahviour.
>>
>> ?
>
> It is lowered to:
>
> f("hello %s", a);
>
> as designed. I don't know what's unwanted about it.
It's unwanted because the lowering calls a function that was not
intended with values that were unintended. You can take this
article: https://dlang.org/articles/hijack.html and replace it
with that lowering behaviour, and have the exact same story.
Also unwanted because of what string interpolation means (ref
wikipedia and all other languages).
More information about the Digitalmars-d-announce
mailing list