Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: better lambda support in the future?

Reply
Thread Tools

Re: better lambda support in the future?

 
 
Jp Calderone
Guest
Posts: n/a
 
      12-18-2004
On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy <(E-Mail Removed)> wrote:
>
> "Jason Zheng" <(E-Mail Removed)> wrote in message
> news:cpvhee$7uh$(E-Mail Removed)...
> > 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
 
Reply With Quote
 
 
 
 
Harlin Seritt
Guest
Posts: n/a
 
      12-18-2004
Jp Calderone wrote:

> On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy <(E-Mail Removed)> wrote:
>>
>> "Jason Zheng" <(E-Mail Removed)> wrote in message
>> news:cpvhee$7uh$(E-Mail Removed)...
>> > 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


A lambda should be used for a one-time, one-line-use function that you have
no intention of calling again (anything more would be an
inefficiency--which you profess not to be fond of). It is not terribly
difficult to come up with a name like "get_name()" or the like and stamp a
"def" in front of with a colon on the end. Then again, it is your program,
you can do whatever you like. In my opinion, I don't see how it can be
productive to make code difficult to read and typing the same series of
keystrokes over and over.

--
Harlin Seritt
 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      12-18-2004
Harlin Seritt wrote:

> Jp Calderone wrote:
>
>

[...]
>> 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

>
>
> A lambda should be used for a one-time, one-line-use function that you have
> no intention of calling again (anything more would be an
> inefficiency--which you profess not to be fond of). It is not terribly
> difficult to come up with a name like "get_name()" or the like and stamp a
> "def" in front of with a colon on the end. Then again, it is your program,
> you can do whatever you like. In my opinion, I don't see how it can be
> productive to make code difficult to read and typing the same series of
> keystrokes over and over.
>


This seems a bit presumptuous. Jp just told you that he found something
difficult, and you dismissively say it isn't.

Frankly I have enough respect for Jp's abilities to believe him when he
says he finds something difficult, as I know he finds things that *IK*
find difficult relatively easy.

Maybe I should enter the next sprint as a name generator ...

regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type of lambda function returning a lambda function... Haochen Xie C++ 4 03-17-2013 11:23 PM
lambda vs non-lambda proc Steve Dogers Ruby 1 03-30-2009 10:11 PM
Build a Better Blair (like Build a Better Bush, only better) Kenny Computer Support 0 05-06-2005 04:50 AM
Re: Lambda as declarative idiom (was RE: what is lambda used for inreal code?) Roman Suzi Python 13 01-07-2005 09:33 PM
better lambda support in the future? Jason Zheng Python 31 12-21-2004 01:30 PM



Advertisments