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

Dukc ajieskola at gmail.com
Thu Jan 28 08:35:34 UTC 2021


On Wednesday, 27 January 2021 at 10:33:53 UTC, Mike Parker wrote:
> [snip]

The DIP states that foo(i"a:${a}, ${b}.") is rewritten as 
`foo(Interp!"a:", a, Interp!", ", b, Interp!".")`. It think it's 
better to rewrite it as `foo(Interp!"a:", Interp!typeof(a)(a), 
Interp!", ", Interp!typeof(b)(b), Interp!".")`. That way, `foo` 
has easier time introspecting which came from the interpolated 
string.

The type of interpolated string literal is very special cased. 
The DIP states it is not an alias sequence, but that it behaves 
like one when passed to a function. And if that does not compile, 
it is treated as string instead. This is going to be full of all 
sorts of corner cases.

Let me suggest an alternative: the user manually chooses the 
type. For example, `i"hello ${world}"` would be rewritten as 
`idup(Interp!"hello ", Interp!typeof(world)(world))`, and 
`I"hello ${world}"` would be `AliasSeq!(Interp!"hello ", 
Interp!typeof(world)(world))`. And with latter I mean an honest 
alias sequence, not one with a special cased `.length` or 
anything like that.



More information about the Digitalmars-d mailing list