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

Dukc ajieskola at gmail.com
Mon Feb 1 16:22:02 UTC 2021


On Monday, 1 February 2021 at 16:10:46 UTC, Adam D. Ruppe wrote:
> On Monday, 1 February 2021 at 16:00:54 UTC, Dukc wrote:
>> Perhaps mixins can be special case to invoke `idup` if any of 
>> their arguments are instanced from `interp`.
>
> Yeah, the grammar could always just special case overload 
> mixin(Interpolated).
>
> Or .stringof could be redefined so like interp!"foo".stringof 
> == "foo" or whatever.

One problem: `.stringof` is supposed to be a source 
representation. "foo" in source represents a string, not part of 
an interpolated string.

>
> .... or just ban it. Make mixin(i"...") a compile error so the 
> user can do their own thing.

I advise against that.

Quoting https://dlang.org/blog/2019/10/15/my-vision-of-ds-future/:
> String interpolation
> 
> I was initially against this, but the more I think about it the 
> more it seems to make
> sense for D. Why? String mixins. Code generation is one of D’s 
> greatest strengths, and
> token strings enable visually pleasing blocks of code that are 
> actually “just strings”.
> String interpolation would make them vastly easier to use. As 
> it happens, there’s a draft > DIP for it in the pipeline.

You don't want to require the user add an extra symbol for every 
interpolated string in it's most important use case.




More information about the Digitalmars-d mailing list