D-etractions A real world programmers view on D

Steven Schveighoffer schveiguy at yahoo.com
Thu Sep 6 07:41:40 PDT 2012


On Wed, 05 Sep 2012 14:22:43 -0400, Nick Sabalausky  
<SeeWebsiteToContactMe at semitwist.com> wrote:


> While a lot of runtime reflection *can* be built in D (even if it
> isn't all there right now), I am kind of annoyed at some of the
> limitations. Like how it's impossible (at either compile-time or
> runtime) to find the subclasses of a class. Uhh, actually that's the
> only limitation I know of. There might be more though.
>

I think this actually is one of the few reflection things possible :)

If you look in druntime, there is a way to iterate over all class TypeInfo  
objects, and you can simply see if the class type inherits from your  
target.

It may be inefficient, but possible (and you can build a tree based on  
this so further lookups are not slow).

-Steve


More information about the Digitalmars-d mailing list