ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-Tutor
python-Tutor
[Tutor] Why lambda could be considered evil
by Scot W. Stevenson other posts by this author
Aug 27 2002 1:07AM messages near this date
Re: [Tutor] Python Cookbook | Re: [Tutor] Python Cookbook
Hello Erik, 

>  But what -is- the problem that some people have with lambda?  

One of the things that annoys me terribly about Python is that its 
beautiful and elegant structure seems to have been mangled in some places 
solely to please powerful and sinister language lobbyists. Usually it is 
some non-intuitive C-esque syntax such as "variable += 23" or "print 'What 
%s does this mean' % abuse" or "print > > someplace, 'I want Python to be 
more like bash!'". In the case of lambda, it is a Lisp construct that 
seems as foreign to Python as an steele [sic] ball shoved up a unicorn's 
nostril. 

I would sum up the main objections as: 

1. It creates a complexity hot spot. Some people seem to be unable to 
resist the temptation to be very, very clever in lambda expressions, to 
the point where it is hard to figure out just what all they are trying to 
do in that one cramped line. Everywhere else, Python makes a point of 
stopping you from being too clever for your own good. 

2. It is hard for newbies to understand why it is needed at all. "Lambda is 
an expression, not a statement" is fine for computer scientists who spend 
lots of time with formal grammars, but to the rest of us it sounds 
suspiciously like "Don't split infinitives". 

3. The name is just plain stupid. Calling "an expression form that 
generates function objects" (Lutz and Ascher) /lambda/ might be intuitive 
if you've spent the last 20 years programming Lisp, but if you're new to 
it all, it just seems like, er, Greek. It isn't even a verb like "import", 
"try", "def(ine)" or "map". If you must have this "expression form", give 
it a mnenomic name or use a generic keyword like "function" instead of 
abusing Southern European alphabets.

So far, nobody has been able to explain to me why you can't just write a 
clean, honest, and readable def instead of shoving everything in a lambda 
expression (except in Tkinter, which was ripped off from Tcl and might 
need those sort of constructs). Fortunately, list comprehensions seem to 
be killing a lot of lambdas, which can only be good - at least they are 
_somewhat_ clearer than lambdas.

Y, Scot

-- 
  Scot W. Stevenson wrote me on Tuesday, 27. Aug 2002 in Zepernick, Germany   
       on his happy little Linux system that has been up for 1679 hours       
        and has a CPU that is falling asleep at a system load of 0.19.        



_______________________________________________
Tutor maillist  -  Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Erik Price
Danny Yoo
Erik Price
Yigal Duppen
Erik Price
Scot W. Stevenson
Yigal Duppen

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved