Re: [Python-Dev] Adventures with ASTs - Inline Lambda

All right, the patch is up on SF. Sorry for the delay, I accidentally left my powerbook about an hour's drive away from home, and had to drive to go get it this morning :) To those who were asking what advantage the new syntax has - well, from a technical perspective there are none, since the underlying implementation is identical. The only (minor) difference is in the syntactical ambiguity, which both forms have - with lambda you can't be certain when to stop parsing the result expression, whereas with 'given' you can't be certain when to stop parsing the argument list. I see the primary advantage of the inline syntax as pedagogical - given a choice, I would rather explain the "given" syntax to a novice programmer than try to explain lambda. This is especially true given the similarity in form to generator expressions - in other words, once you've gone through the effort of explaining generator expressions, you can re-use most of that explanation when explaining "function expressions"; whereas with lambda, which looks like nothing else in Python, you have to start from scratch. -- Talin

talin> ... whereas with 'given' you can't be certain when to stop talin> parsing the argument list. So require parens around the arglist: (x*y given (x, y)) Skip

skip@pobox.com wrote:
I would not be opposed to mandating the parens, and its an easy enough change to make. The patch on SF lets you do it both ways, which will give people who are interested a chance to get a feel for the various alternatives. I realize of course that this is a moot point. But perhaps I can help to winnow down the dozens of rejected lambda replacement proposals to just a few rejected lamda proposals :) -- Talin

Talin wrote:
Another ambiguity is that when they're optional it is unclear whether or not adding them means the callable now expects a tuple argument (i.e., doubled parens at the call site). If they're mandatory, then it is clear that only doubled parentheses at the definition point require doubled parentheses at the call site (this is, not coincidentally, exactly the same rule as applies for normal functions).
Heh. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org
participants (3)
-
Nick Coghlan
-
skip@pobox.com
-
Talin