better lambda support in the future?

Jp Calderone exarkun at divmod.com
Fri Dec 17 19:11:06 EST 2004


On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy <tjreedy at udel.edu> wrote:
>
> "Jason Zheng" <jzheng at jpl.nasa.gov> wrote in message 
> news:cpvhee$7uh$1 at nntp1.jpl.nasa.gov...
> > Steven Bethard wrote:
> >> Jason Zheng wrote:
> >>
> >>> I'm wondering why python still has limited lambda support. What's 
> >>> stopping the developers of python to support more lisp-like lambda 
> >>> function?
> 
> They already have: given the fundamental syntax difference between all 
> expressions and expressions within statements, def statements are at least 
> the equivalent of lisp lambdas + name binding.  When you get an exception 
> traceback, a unique name is more helpful than the pseudoname <lambda>. 
> Isolating the definition of a function in a separate statement also makes 
> it possible to unittest the function.
> 
> >> This comes up every few weeks on the list.  If you haven't already, 
> >> check the archives in Google for 'anonymous def' or 'anonymous 
> >> function'.  The usual response to this question is something along the 
> >> lines of "if it's good enough to create a function for, it's good enough 
> >> to name".
> 
> What puzzles me is 1) why some people apparently think anonymity is good --  
> is it really that hard to name non-trivial functions? and 2) why some 
> people are so quick to recommend changes to Python before they understand 
> what they can already do (wth def statements, in this case).

  Regarding #1: there must be a great variance between people in the 
difficulty of some aspects of programming.  I am always amazed to hear 
from people who have no difficulty picking names for all of their 
functions.  This is a task that often stumps me for long minutes.  Given 
the obvious profusion of functions in most programs, these minutes compound
into hours very quickly.  I am always greatful when a lambda lets me avoid 
wasting time on something as irrelevant as giving a name to a short 
function that will be referenced exactly once.

  I am quite envious of those who can easily come up with names for any
function.  Perhaps you lot should go a bit easier on the rest of us and 
let us keep our crutches.  After all, Python is a language which is 
supposed to make me more productive by letting me ignore irrelevant things,
not force me to waste time on them.  Why should this part of the langauge 
be any different?

  Jp



More information about the Python-list mailing list