What do you thing about this string interpolation idea

Daniel Kozak kozzi11 at gmail.com
Mon Dec 10 10:11:44 UTC 2018


https://run.dlang.io/is/FbOnGI

import std.stdio;
template somefun()
{
      auto iterpolate(string s)()
      {
          //do some parsing
          return mixin(s[1 .. $]);
      }
}

enum enableInterpolate = "mixin somefun A; alias interpolate = 
A.iterpolate;";

void main()
{
     mixin(enableInterpolate);
     int a = 5;
     iterpolate!("$a").writeln;
}




More information about the Digitalmars-d mailing list