Re: Knowing about Inheritance

"Mark Hahn" <[email protected]> Thu, 29 Jul 2004 08:08:39 -0700
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
Paul Prescod wrote:
> I have an object that would like to know whenever it is inherited
> from. In Python you do this with metaclasses. How do you do it in
> Prothon?
>
> I'm trying to implement this recipe:
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/204349

Are you sure you gave me the correct link?  That is "Metaclass for Interface
Checking" and it has no capability of detecting what has inherited from
what.  It just checks for classes containing attributes.  That would be
trivial in Prothon using "attr in class.attrs_".

Getting back to your original question:  Would it be alright do define
inheritance as that which has gone through the call_ init_ process?  In that
case it would be easy as you could just override the call_ or init_ for the
class you want to track.

You can't do it in general for any prototype link because anyone that owns a
pointer to an object can use that pointer as a parent prototype link without
the object's knowledge.  I could add a hook to the interpreter for this
purpose if you wish.