Is there a rational behind not allowing statements inside mixin templates? I know mixin does accept code containing statements, but using mixin is much uglier. so I was wondering.

example use case:
//---------------------------------
int compute(string)
{
    return 1;
}

mixin template testBoilerPlate(alias arg, alias expected)
{
    {
        import std.format : format;
        auto got = compute(arg);
assert(got == expected, "expected %s got %s".format(expected, got));
    }
}

unittest
{
    mixin testBoilerPlate("12345", 1);
    mixin testBoilerPlate("00" ~ "0", 2 - 1);
}
//--------------------------------

Reply via email to