PEP 312 - Making lambdas implicit worries me, surely it's just the name 'lambda' that is bad...
Erik Max Francis
max at alcyone.com
Mon Mar 3 14:40:16 EST 2003
Alexander Schmolck wrote:
> Do you think adding a few keystrokes by replacing
>
> >>> a + b * c[2]
>
> with the more explict
>
> >>> a operatorAddOrMaybeConcatenate (b operatorMultiplyOrMaybeRepeat
> c
> ... operatorAtIndexOrMaybeKey 1)
>
> would make python unusable? Or maybe just unpopular?
Just as using fewer keystrokes for its own sake is not a laudable goal,
neither is using more keystrokes for its own sake. Since nobody's
proposed anything like the above, it's a red herring.
> (Hint: in case the point of how mere "differences in keystrokes" can
> widely
> affect design choices in a language and its libraries was lost on you;
> do you
> really think anyone would dream of introducing a ternary operator if
> you could
> just do
>
> def when(cond, a,b):
> if cond: return a()
> else: return b()
>
> res = when(cond, :b, :c)
>
> instead of
>
> res = when(cond, lambda : b, lambda :c)
In a word, yes, because in a conditional operator the lazy evaluation is
implicit. You can forgot the lambdas/colons in the non-short-circuiting
version.
The point here is that terseness in and of itself is not a laudable
goal, especially for Python. Readability is far more important to me
than terseness. Considering that the functionality for this already
exists with the addition of _one_ extra keyword, offering the ability to
remove that lambda in the corner case of a zero-argument thunk does not
seem attractive; it makes it shorter, but it makes it less readable. I
want Python to be more Pythonic, not more like Perl.
That Smalltalk has a particularly compact form for expressing explicit
lazy evaluation is fine for Smalltalk. But that has no bearing on
whether Python should also have a compact form _for the sole purpose of
being compact_. Especially since getting the same effect in Python is
so straightforward.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ Strange is our situation here upon earth.
\__/ Albert Einstein
Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
An Esperanto reference for English speakers.
More information about the Python-list
mailing list