String Interpolation

Steven Schveighoffer schveiguy at gmail.com
Sun Oct 22 21:55:23 UTC 2023


On Sunday, 22 October 2023 at 21:32:15 UTC, Arafel wrote:
> On 22/10/23 22:44, Adam D Ruppe wrote:
>> What's your evidence for this?
>
> There's obviously no scientific evidence, because I don't think 
> anybody has researched the topic.
>
> But as an example, and perhaps ironically, let me point you to 
> none other than yourself (or at least something co-authored by 
> yourself). From 
> [DIP1036](https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1036.md#description):
>
> > The primary use case is to employ the literal in place of a
> string-yielding expression:
> >
> > ```d
> > void foo(string s);
> >
> > foo(i"Hello, my name is ${name} and I am ${age} years old.");
> >
> > string s = i"${var1} + ${var2} = ${var1 + var2}";
> > ```

FWIW, that is something Adam opposed, but I insisted on. I did 
not think a String Interpolation DIP would be viable without it.

I still feel like one should be able to use an interpolation 
tuple as a string, but it's really hard to come up with a design 
that doesn't feel like a complete hack.

It's indeed much much simpler to just push that requirement to 
build a string if desired on the user.

-Steve


More information about the Digitalmars-d mailing list