Get specific functions of unknown type at runtime?

Adam D. Ruppe destructionator at gmail.com
Mon Dec 17 06:49:03 PST 2012


On Monday, 17 December 2012 at 07:54:08 UTC, F i L wrote:
> I have an alternative in mind, but first, is there a possible 
> way for a Super class to ask about a derivative's members 
> during constructions? (I'm guessing not). Something like:

Not that I know of, no. Though maybe a templated constructor 
could so some magic.

class SceneObject {
    this(T)(T t) { ... }
}

class Person : SceneObject {
     this() { super(this); } // calls the templated superclass 
magic, which will have T == Person
}

But this isn't that much different than the mixin approach in 
that you still have to do something special with the child 
classes.


My dmd segfaults when I don't put a constructor in the child 
class at all... I think there's bug fixes coming in the new dmd 
about these templated constructors so it might get better. idk.


More information about the Digitalmars-d-learn mailing list