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

Paul Backus snarwin at gmail.com
Mon Feb 1 17:06:36 UTC 2021


On Monday, 1 February 2021 at 16:40:54 UTC, Adam D. Ruppe wrote:
> Consider this too: mixin(i"hi ${a+b}") - without the special 
> rule - would expand to mixin("hi ", "a+b") so even that a+b is 
> interpreted in a different scope.

No, you've added an extra level of quoting by mistake. It would 
expand to `mixin("hi ", a+b)`. The expression `a+b` would be 
evaluated using CTFE, and then .stringof (i.e., the .toString 
method) would be called on the result. Here's the relevant 
frontend code:

https://github.com/dlang/dmd/blob/v2.095.0/src/dmd/expressionsem.d#L91


More information about the Digitalmars-d mailing list