[Python-3000] Compiling the PEP 3115 metaclass syntax

Steven Bethard steven.bethard at gmail.com
Thu Mar 15 04:43:31 CET 2007


On 3/14/07, Robert Brewer <fumanchu at amor.org> wrote:
> Guido van Rossum wrote:
>  > The PEP proposes that the class statement accepts
>  > keyword arguments, *args, and **kwds syntax as well
>  > as positional bases. This is a bit messy to compile
>  > and execute, but we already have this, of course, in
>  > the code for calling regular functions.
>  >
>  > So I think it would be acceptable to this into a
>  > call to a new (hidden) built-in function, named
>  > __build_class__. Then that this class definition:
>  >
>  >   class C(A, B, metaclass=M, other=42, *more_bases,
>  > *more_kwds):
>  >    ...
>  >
>  > would translate into this:
>  >
>  >   C = __build_class__(<func>, 'C', A, B, metaclass=M,
>  > other=42, *more_bases, *more_kwds)
>
>  This sounds familiar ;)
> http://mail.python.org/pipermail/python-dev/2004-March/043562.html
>
>  Why not just call that function "class" and get it over with? ;)

That certainly has an appeal.  Then you'd have::

    class <name>(<*args>, <**kwargs>):
        <body>

translated into::

    <name> = class(<bodyfunc>, <name>, <*args>, <**kwargs>)

And in Python 4000, we can allow any function instead of just "class",
and we can basically get the "make" statement PEP. ;-)

STeVe
-- 
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy


More information about the Python-3000 mailing list