pre-PEP: The create statement
Steven Bethard
steven.bethard at gmail.com
Thu Apr 6 11:41:39 EDT 2006
Carl Banks wrote:
> Steven Bethard wrote:
>> This PEP proposes a generalization of the class-declaration syntax,
>> the ``create`` statement. The proposed syntax and semantics parallel
>> the syntax for class definition, and so::
>>
>> create <callable> <name> <tuple>:
>> <block>
>>
>> is translated into the assignment::
>>
>> <name> = <callable>("<name>", <tuple>, <namespace>)
>>
>> where ``<namespace>`` is the dict created by executing ``<block>``.
>> The PEP is based on a suggestion [1]_ from Michele Simionato on the
>> python-dev list.
>
> And who needs a class statement after that?
>
> create type A:
> <block>
>
> That's probably even more readable than class A, if not as familiar.
> My biggest concern with this is the special arguments of the caller.
> It breaks my heart that we couldn't do something like this:
>
> create dict keymap:
> A = 1
> B = 2
>
> And it'll probably confuse people as well. We ought to keep that in
> mind.
This is definitely an important point. I've thought about this a bit
and I'm still not sure which way is the right way to go on this. If the
tuple and dict arguments actually get passed as *args and **kwargs
arguments, the create statement could be used with a much wider variety
of existing callables. I've updated the open issues section of the PEP
to point this out.
STeVe
More information about the Python-list
mailing list