What do you thing about this string interpolation idea
Atila Neves
atila.neves at gmail.com
Mon Dec 10 15:39:07 UTC 2018
On Monday, 10 December 2018 at 10:11:44 UTC, Daniel Kozak wrote:
> 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;
> }
Nice.
More information about the Digitalmars-d
mailing list