Kaz Kylheku wrote: > Kaz Kylheku wrote: > > But suppose that the expression and the multi-line lambda body are > > reordered? That is to say, the expression is written normally, and the > > mlambda expressions in it serve as /markers/ indicating that body > > material follows. This results in the most Python-like solution. > > Unfortunately, while this idea has intuitive appeal,
It does? Didn't seem so in the responses you got so far, did it... ;-) SCNR > it leaves some > problems to solve; namely, lambdas that occur in expressions embedded > within statement syntax which has body material of its own. For > instance > > # lambda defined and immediately called here > if lambda(x)(4) < 0: > print "a" > elif y = 4: > print "b" > else: > print "foo" > > Where to stick the lambda body? It's not hard to come up with > straightforward answers, except that they are not particularly > appealing. One rule might be that the lambda bodies have to be placed > immediately after the statement body material, set off by the lambda: > thing. In the case of if/elif/else, they have to be placed behind the > closest suite that follows the expression in the syntax of the > statement: > > if lambda(x)(4) < 0: > print "a" > lambda: > return x + 1 > elif y = 4: > print "b" > else: > print "foo" > > The overall rule is simple and uniform: each suite can have lambda: > clauses. These have to match lambda() occurences in the expression (or > expression list) immediately to the left in the same grammar > production. Sorry to tell you this, but I think that kind of thing is exactly what the BDFL had in mind when he talked about "Rube-Goldberg-Devices" in Python... -- http://mail.python.org/mailman/listinfo/python-list