Getting derived classes

dsimcha dsimcha at yahoo.com
Thu Oct 16 19:18:34 PDT 2008


== Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
> dsimcha wrote:
> > I know that, in std.traits, there's a template that spits out all base classes
> > for a given class.  Based on reading the source, it seems to work based on a
> > rather interesting use case for is expressions.  Is there any equivalent way
> > to do the opposite:  For any given position in a class hierarchy, to get a
> > tuple of all possible descendants?
> That's not possible in general because in D the derived classes form an
> open set. I guess it could be done at runtime via reflection (not
> implemented afaik), but not at compile time.
> Andrei

Not quite sure I understand why this has to be the case.  Somewhere in the docs,
Walter explicitly says that, since D knows about the whole class tree, the
compiler can figure out which functions in a hierarchy can be made non-virtual.
If this is the case, why is the compiler not able to know about the whole class
tree for purposes of creating lists of derived classes?



More information about the Digitalmars-d mailing list