In a blog post back in 2008, I wrote...
My favourite rejected/withdrawn Python Enhancement Proposal (PEP) is Steven Bethard's PEP 359 based on an idea by Michele Simionato. That's not to say I disagree with Guido not wanting it in Python, but I like aspects of the idea conceptually as part of a possible Python-like language.
Consider the class statement (take from the PEP):
class C(object):
x = 1
def foo(self):
return 'bar'
This, as the PEP points out, is equivalent to:
C = type('C', (object,), {'x':1, 'foo':<function foo at ...>})
And more generally:
class <name> <bases>:
__metaclass__ = <metaclass>
<block>
is syntactic sugar for:
<name> = <metaclass>("<name>", <bases>,
<dictionary created by executing block>)
The PEP points out that the class statement nicely avoids the need to mention the name twice and also does the task of executing a block of statements and creating a dictionary of the bindings that result.
It then proposes a make statement of the following form:
make <callable> <name> <tuple>:
<block>
that would basically make the class statement syntactic sugar usable for other things. See the PEP itself for a bunch of interesting this this would allow in Python. I certainly think it makes metaclasses clearer.
But my interest isn't so much in Python, but just thinking about a language where something like this is core.