digitalmars.D - mixin extension (question)
- Andrew Edwards (26/26) Jul 23 2004 Is it possible, or would it even be feasible, to extend mixins such that...
- Sha Chancellor (9/35) Jul 23 2004 How is this good or usefull? Or how is it different from doing:
Is it possible, or would it even be feasible, to extend mixins such that
the scope of a given mixin terminates upon encountering another mixin?
For example:
template someMixin(){ int x; }
template someOtherMixin(){ int y; }
class someClass {
mixin someMixin;
void foo() {
int x; // error: x already defined
x = 10;
mixin someOtherMixin; // end of someMixin (within foo())
y = 10;
int xy = x * y; // error: x not defined
}
mixin someOtherMixin;
writef(x * y); // outputs 100
}
I can see that there's already allot of problems with this idea. Maybe
it would be better if we could explicitly terminate the lifespan of a
particular mixin?
mixin someMixin;
x = 10;
remove someMixin;
writef(x); // error; x not defined
Any thoughts?
Andrew
Jul 23 2004
In article <cdsco0$ig$1 digitaldaemon.com>, Andrew Edwards says...
Is it possible, or would it even be feasible, to extend mixins such that
the scope of a given mixin terminates upon encountering another mixin?
For example:
template someMixin(){ int x; }
template someOtherMixin(){ int y; }
class someClass {
mixin someMixin;
void foo() {
int x; // error: x already defined
x = 10;
mixin someOtherMixin; // end of someMixin (within foo())
y = 10;
int xy = x * y; // error: x not defined
}
mixin someOtherMixin;
writef(x * y); // outputs 100
}
I can see that there's already allot of problems with this idea. Maybe
it would be better if we could explicitly terminate the lifespan of a
particular mixin?
mixin someMixin;
x = 10;
remove someMixin;
writef(x); // error; x not defined
Any thoughts?
Andrew
How is this good or usefull? Or how is it different from doing:
void foo() {
{ mixin someMixin;
}
{ mixin someOtherMixin;
}
}
What are you trying to accomplish?
Jul 23 2004








Sha Chancellor <schancel pacific.net>