A critic of Guido's blog on Python's lambda
Ken Tilton
kentilton at gmail.com
Thu May 11 00:20:46 EDT 2006
Alex Martelli wrote:
> Stefan Nobis <snobis at gmx.de> wrote:
>
>
>>aleax at mac.com (Alex Martelli) writes:
>>
>>
>>>if anonymous functions are available, they're used in even more
>>>cases where naming would help
>>
>>Yes, you're right. But don't stop here. What about expressions? Many
>>people write very complex expression, that are hard to understand. A
>>good language should forbid these abuse and don't allow expressions
>>with more than 2 or maybe 3 operators!
>
>
> That would _complicate_ the language (by adding a rule). I repeat what
> I've already stated repeatedly: a good criterion for deciding which good
> practices a language should enforce and which ones it should just
> facilitate is _language simplicity_. If the enforcement is done by
> adding rules or constructs it's probably not worth it; if the
> "enforcements" is done by NOT adding extra constructs it's a double win
> (keep the language simpler AND push good practices).
Gosh, that looks like fancy footwork. But maybe I misunderstand, so I
will just ask you to clarify.
In the case of (all syntax imaginary and not meant ot be Python):
if whatever = 42
dothis
do that
do something else
else
go ahead
make my day
You do not have a problem with unnamed series of statements. But in the
case of:
treeTravers( myTree, lambda (node):
if xxx(node)
print "wow"
return 1
else
print "yawn"
return 0)
...no, no good, you want a named yawnOrWow function? And though they
look similar, the justification above was that IF-ELSE was lucky enough
to get multiline branches In the Beginning, so banning it now would be
"adding a rule", whereas lambda did not get multiline In the Beginning,
so allowing it would mean "adding a construct". So by positing "adding a
rule or construct" as always bad (even if they enforce a good practice
such as naming an IF branch they are bad since one is /adding/ to the
language), the inconsistency becomes a consistency in that keeping IF
powerful and denying lambda the same power each avoids a change?
In other words, we are no longer discussing whether unnamed multi-line
statements are a problem. The question is, would adding them to lambda
mean a change?
Oh, yeah, it would. :)
hth, kenny
--
Cells: http://common-lisp.net/project/cells/
"Have you ever been in a relationship?"
Attorney for Mary Winkler, confessed killer of her
minister husband, when asked if the couple had
marital problems.
More information about the Python-list
mailing list