Where are we with thoughts on string interpolation and mixins?

aliak something at something.com
Tue Nov 20 13:16:13 UTC 2018


On Tuesday, 20 November 2018 at 12:47:34 UTC, Zoadian wrote:
>
> The point I was trying to make is: I think we can build 
> something like this (https://run.dlang.io/is/NjHUah):

Ok I may have slightly missed that point :o, sorry.

But yeah, I actually mentioned that in the post as well -> 
https://code.dlang.org/packages/stri

You mean that kinda thing?

>
> ```
> import std.stdio;
> import std.array;
> import std.traits;
>
> string sinterp(string code, alias P1)() {
>     string s = code;
>     s = s.replace("$"~__traits(identifier, P1), P1);
>     return s;
> }
>
> void main() {
>     enum txt = "auto test";
>     pragma(msg, sinterp!(`$txt = 3;`, txt));
>     mixin(sinterp!(`$txt = 3;`, txt));
> }
> ```

mixin(sinterp!(`$txt = 3;`));

Vs

mixin("$txt = 3;");

I mean ... Add context, add more strings, and more complication 
and the level of noise just ++ to point of it becoming 
unnecessarily stressful to review code no?



More information about the Digitalmars-d mailing list