Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2

Steven Schveighoffer schveiguy at gmail.com
Fri Jan 29 19:51:52 UTC 2021


On 1/29/21 2:42 PM, Paul Backus wrote:
> On Friday, 29 January 2021 at 19:35:55 UTC, Steven Schveighoffer wrote:
>> On 1/29/21 2:33 PM, Paul Backus wrote:
>>>
>>> Ok, you got me, I forgot a `typeof`:
>>>
>>>      anySatisfy!(isSomeString, typeof(i"I have ${count} apples"))
>>
>> Returns true.
>>
> 
> Not the way the DIP is currently written. `typeof` can accept an 
> expression tuple, and evaluates to a type tuple when it does; e.g.,
> 
>      static assert(is(typeof(AliasSeq!(1, 2.0, "hello")) == 
> AliasSeq!(int, double, string)));

https://github.com/dlang/DIPs/blob/344e00ee2d6683d61ee019d5ef6c1a0646570093/DIPs/DIP1036.md#a-string-interpolation-sequence-is-not-a-value-tuple

The intention is for anything other than a function call or template 
that accepts the expanded form to treat it as a string type. This means 
typeof too. I should add it to the examples there.

It's like a polysemous string literal:

void foo(immutable char *);

foo("hello"); // ok, compiler makes it work
pragma(msg, typeof("hello")); // string, not immutable char *;
auto x = "hello";
foo(x); // error

-Steve


More information about the Digitalmars-d mailing list