chaining

Brian digitalmars at brianguertin.com
Thu Feb 26 00:01:48 PST 2009


On Wed, 25 Feb 2009 22:08:43 +0000, BCS wrote:
> template BaseT(){
>     typeof(this) foo()(int x_) {
>         this.x = x_;
>         return this;
>     }
> }
> class Base {
>     int x;
>     mixin BaseT!();
> }
> 
> template DerivedT()
> {
>     typeof(this) bar(int y_) {
>         return this;
>     }
>     mixin BaseT!();
> }
> class Derived : Base {
>     mixin DerivedT!();
> }

hmm.. is that really the best way? if the function has 10 lines of code 
and is mixed into to 15 classes thatll give me 15 times the code for that 
one function i think. also gets a bit tricky when i want to override some 
of the functions. (by using another class in between base and derived?). 
i think i need a new plan..


More information about the Digitalmars-d-learn mailing list