Getting derived classes

Denis Koroskin 2korden at gmail.com
Thu Oct 16 19:26:18 PDT 2008


dsimcha <dsimcha at yahoo.com> писал(а) в своём письме Fri, 17 Oct 2008  
06:18:34 +0400:

> == 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?

How do you get a list of all classes that derive from Object?
I might write one, too! Imagine we compile the source separately and then  
link obj files together.



More information about the Digitalmars-d mailing list