On Wednesday, 5 March 2014 at 23:33:25 UTC, Frustrated wrote:
Maybe the problem isn't what I thought it was. I created a test case that works:

import std.stdio, std.cstream;

mixin template C()
{
        alias A = typeof(this);
        mixin(B!(A));
}

template B(T)
{
        pragma(msg, T);
enum B() { return "string foo() { return `<"~T.stringof~">`; }"; }
}

class A
{
        //mixin(B!(A));
        mixin C;
}


void main()
{
        auto a = new A;
        writeln(a.foo());
        //a.B();
        din.getc();
}


Note the difference in calls. C is much easier because you don't have to pass the parent type. This is all I'm trying to achieve in the other code but when I do the functions(foo in this case) do not get mixed in.


The actual error is quite strange in the other code:

When I simply wrap the code in an outside template I get the error(s)

Eror: gui.border is not an lvalue       

which is related to the line

auto ress = (gui.border = bb);

which works when I don't wrap the code. If I stick the output of the string mixin template directly into the class, it works fine. (so it has something to do wtih the template generation rather than what it generates)

e.g., this is what I did

template AbstractToInterface(B, T...)
{       
        enum AbstractToInterface() { .... }
}

to

mixin template AbstractToInterface(B, T...)
{
        mixin(AbstractToInterface2!(B, T));
}

template AbstractToInterface2(B, T...)
{       
        enum AbstractToInterface2() { .... }
}

and convert

mixin(AbstractToInterface!(WindowsGui, iButton, WindowsButton, iBorder, WindowsBorder));

to

mixin AbstractToInterface!(WindowsGui, iButton, WindowsButton, iBorder, WindowsBorder);


and I get the error down the road about

Eror: gui.border is not an lvalue

Which I guess is saying border does not have a setter, which is what AbstractToInterface is suppose to be creating and adding... again, it works when I copy the output of the template direct to the class.

I'm betting it's a bug unless I'm doing something real stupid.

Reply via email to