[Python-Dev] anonymous blocks
Ka-Ping Yee
python-dev at zesty.ca
Fri Apr 22 01:49:36 CEST 2005
On Thu, 21 Apr 2005, Guido van Rossum wrote:
> Perhaps it could be even simpler:
>
> [assignment_target '=']* expr ':' suite
>
> This would just be an extension of the regular assignment statement.
It sounds like you are very close to simply translating
expression... function_call(args):
suite
into
expression... function_call(args)(suitefunc)
If i understand what you proposed above, you're using assignment
as a special case to pass arguments to the inner suite, right? So:
inner_args = function_call(outer_args):
suite
becomes:
def suitefunc(inner_args):
suite
function_call(outer_args)(suitefunc)
?
This could get a little hard to understand if the right-hand side
of the assignment is more complex than a single function call.
I think the meaning would be unambiguous, just non-obvious. The
only interpretation i see for this:
x = spam('foo') + eggs('bar'):
suite
is this:
def suitefunc(x):
suite
spam('foo') + eggs('bar')(suitefunc)
but that could seem a little too mysterious. Or you could (in a
later compiler pass) forbid more complex expressions on the RHS.
On another note, would there be any difference between
x = spam():
suite
and
x = spam:
suite
?
-- ?!ng
More information about the Python-Dev
mailing list