I'm trying to cut down on some boilerplate with this function:

const string link (alias variable) ()
{
        const string name = __traits (identifier, variable);
        return name~`= glGetUniformLocation (program, "`~name~`");`;
}

Applied in this kind of context:
                
this ()
{
        super ("default.vert", "gradient.frag");
        mixin link!start_color;
        mixin link!final_color;
        mixin link!center_pos;
        mixin link!lerp_vec;
        mixin link!lerp_range;
}
                                        

And the first mixin in every such function works fine, but the rest don't. Specifically, I get this error:

source/main.d(483): Error: mixin link!final_color link isn't a template

for each mixin after the first. If I put the argument to mixin in parenthesis:

mixin (link!start_color);

I get:

source/main.d(483): Error: value of 'this' is not known at compile time

Finally, removing the parenthesis and putting each mixin statement in its own block:

{mixin link!start_color;}

compiles, but the mixed-in string has no apparent effect.

Is this a bug or am I doing it wrong?

Reply via email to