[Types-sig] Re: Meta-classes discussion starter

Donald Beaudry Donald Beaudry <donb@tensilica.com>
Tue, 01 Dec 1998 13:49:00 -0500


Just van Rossum <just@letterror.com> wrote,
> At 10:36 AM -0500 12/1/98, Donald Beaudry wrote:
> >It's interesting to note that a patch is not necessary.  All you need is
> >an extension module that exports a hand written meta-class.  This
> >meta-class can then poke into the class that's being defined and check
> >for the existence of the __class__ attribute.
> 
> But then you don't have the advantage which was the main reason to make
> that patch, which is that you don't have to spell it like:
> 
> class A(some_extension_object):
>     __class__ = whatever
> 
> but that the following "just works":
> 
> class A:
>     __class__ = mymetahook
> 
> Or do I miss something here?

Nope... I dont think you are missing anything.  I just dont mind using
some_extension_object as base class as much as you do.  

> On a related note, would my hook break your stuff?

I guess that depends on how you define "break" ;) The stuff I did was
mostly an experiment to play with the syntax for defining
meta-classes.  With your change it's likely that it wont work as is,
but I doubt that it works with 1.5 anyways (though I might have fixed
it, I dont really remember).  For the most part, it has served its
purpose.  If more people look at it, it might continue to serve its
purpose... it does, afterall, raise a few more issues.

> The test to see whether the method dict contains a __class__ entry
> happens *before* the tests that check whether one of the base
> classes either has a callable type or has a __class__ attr. If it
> does (break your stuff), maybe I should reverse the tests, although
> that would make the hook less elegant.

I suppose we could put off this part of the discussion until Guido
says that he's interested in the patch.

	--Don