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
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
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
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
x = spam: suite