July 24, 2004
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
July 24, 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?