Does D have syntax for adding subscopes to classes?

GregoryP via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 12 08:21:26 PDT 2015


I'm just wondering if, or how much of the following is possible 
in some way in D:

class Foo {
     int x;
     sub Bar {
         int x;
         int getFooX(){ return super.x; }
         sub FooBar {
             int x;
             int y;
             int addXes(){ return x + super.x + super.super.x; }
         }
     }
}

Where the Xes are accessible outside the class by Foo.x, 
Foo.Bar.x, Foo.Bar.FooBar.x.


More information about the Digitalmars-d-learn mailing list