At 06:26 PM 3/14/2007 -0700, Guido van Rossum wrote:
>(It's a slightly
>different function than currently; the current function *returns* the
>locals, while the new one *takes* the locals as an argument; instead
>of a LOAD_LOCALS opcode we need a STORE_LOCALS opcode.)

Wouldn't it suffice to exec a code object with the specified locals?  Then 
the class suite wouldn't even need to be a function, since it would neither 
accept parameters nor return results.  And no new opcode would be needed.

So in this:

>def __build_class__(func, name, *bases, metaclass=None, **kwds):
>     if metaclass is None:
>         metaclass = extract_metaclass(bases)  # may raise an exception
>     prepare = getattr(metaclass, "__prepare__", None)
>     if prepare:
>         locals = prepare(name, bases, **kwds)
>     else:
>         locals = {}
>     func(locals)
>     return metaclass(name, bases, locals, **kwds)

we would change 'func' to 'code' and instead of func(locals) we would 'exec 
code in globals, locals'.

_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to