https://dpaste.dzfl.pl/fb49bf834cff

import std.stdio;

auto Q(string A)()
{
        auto foo()
        {
                auto d = mixin(Z!(A)());
                return d;
        }
        return foo()();
}

auto X(string A, string N)()
{
        return N~" = (() { int y = 4;  return "~A~" + y + 5; })();";
}

auto Z(string A)()
{
        return "() { int y = 4;  return "~A~" + y + 5; }";
}


void main()
{
        int x = 3;
        double y = 0;
        pragma(msg, (X!("x", "y")()));
        mixin(X!("x", "y")());
        y = Q!("x")();
        
        writeln(y);
}

using Q is more ideomatic but foo does not have access to x which is required(since Q should behave like a string mixin as far as scope is concerned).

Reply via email to