The state of string interpolation
Martin Tschierschke
mt at smartdolphin.de
Sat Dec 8 19:17:26 UTC 2018
On Thursday, 6 December 2018 at 00:32:48 UTC, Adam D. Ruppe wrote:
> On Thursday, 6 December 2018 at 00:20:53 UTC, H. S. Teoh wrote:
>> Why can't this be added to to code.dlang.org as a library /
>> dub package / whatever?
>
> Library things cannot access the local scope of the string
> unless you mixin.
>
> So
>
> mixin(interp!"foo #{a}");
>
> is doable as a library (and I know Nick Sabalusky's scriptlike
> has it, probably among others), but
>
> string b = "foo #{a}";
>
> is only doable as a language feature.
I am referring to this post, because it is the first mentioning
the mixin way in this thread:
Why is mixin() not allowed in UFCS?
it may become way nicer, and with an alias i=interp; we would have
=>
writeln(i!"foo #{a}".mixin) // which is not to far away from
writeln(i"foo #{a}")
or:
i!"foo #{a}".mixin.writeln;
More information about the Digitalmars-d
mailing list