Composite Pattern and simplificaton

JS js.mdnq at gmail.com
Wed Jul 3 03:12:33 PDT 2013


Is there any nifty D features that allow one to simplify the 
composite pattern,

e.g.,

     class A : B
     {
         B b;
     }

Where I would like to have class A's implementation of B be use 
b. This would avoid a lot of boilerplate code if just redirecting 
A's implementation of B to b.

e.g.,

    class A : B(use b)
    {
        B b;
    }


or maybe more D'ish

    class A : B
    {
       B b;
       alias b A:B;
    }

probably some fancy mixin could be used:

    class A : B
    {
       B b;
       mixin simpleComposite(b);   // Just implements B with 
redirection to b
    }



More information about the Digitalmars-d mailing list