The state of string interpolation

Steven Schveighoffer schveiguy at gmail.com
Sat Dec 8 03:15:47 UTC 2018


On 12/7/18 10:11 PM, Jonathan M Davis wrote:
> On Friday, December 7, 2018 7:29:10 PM MST Steven Schveighoffer via
> Digitalmars-d wrote:
>> On 12/7/18 9:04 PM, Jonathan M Davis wrote:
>>> On Friday, December 7, 2018 5:58:43 PM MST o via Digitalmars-d wrote:
>>>> On Friday, 7 December 2018 at 23:56:48 UTC, Adam D. Ruppe wrote:
>>>>> On Friday, 7 December 2018 at 23:46:45 UTC, o wrote:
>>>>>> Also, see Andrei's comment:
>>>>>> https://github.com/dlang/dmd/pull/7988#issuecomment-375760720
>>>>>
>>>>> He seems to also have the misunderstanding that was common
>>>>> earlier in this thread that tuple == std.typecons.
>>>>
>>>> This is probably going to confuse more people, so we should refer
>>>> to them as "sequences" in the DIP. Also, I am calling it "String
>>>> Sequence Literals" instead of "String Interpolation" because it
>>>> is more broad - more than just interpolation can be done with
>>>> this.
>>>
>>> Personally, I'd just use the term AliasSeq, because that's what the
>>> associated template for them in Phobos is called. Just about anything
>>> else is going to be confusing. It's really unfortunate that Walter
>>> originally decided to call them tuples given that they aren't quite
>>> tuples, but there really isn't a good term for them ultimately. As it
>>> is, AliasSeq was just the best of a bad set of choices, but at least
>>> it's clear what you mean what you use the term, whereas just about
>>> anything else breeds confusion.
>> But it's not an AliasSeq. It's simply a list of items.
>>
>> for example, I want this to work:
>>
>> writeln(i"a + b = ${a+b}");
>>
>> And this compiles:
>>
>> writeln("a + b = ", a + b);
>>
>> But this does not:
>>
>> writeln(AliasSeq!("a + b = ", a + b));
> 
> *sigh* So, we'd be creating yet another similar concept with this? That
> seems really questionable. I can see why you'd want something like i"a + b =
> ${a+b}" to work, but we already have enough confusion around "tuples" as it
> is without trying to add a third kind.

I don't believe it's much different from tuple.expand. But I don't know 
what the limitations of the existing tuple-like things are.

Really, I just wanted it to expand into "as if you typed all those 
things individually separated by commas".

-Steve


More information about the Digitalmars-d mailing list