www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - mixin trouble

This will get you in trouble, sending the compiler in an endless loop allocating
a lot of memory:

template relink(T) {
class foo {
private:
public:
void something() {
}
}
class foo2 {
private:
public:
// constructor cannot access frame of function main, though
// it is never constructed, or directly part of main.
this() {
// commenting this out will fix the problem
singleton.something();
}
}
// this won't logically work for foo2's 'something'.
// though, it will if you remove the call.
// i'm not sure about what's causing the trouble.
foo singleton = new foo;
}

int main(char[][] args) {
mixin relink!(int);	
return 0;
}
Sep 06 2004