Re: better lambda support in the future?

Discussion in 'Python' started by Jp Calderone, Dec 18, 2004.

  1. Jp Calderone

    Jp Calderone Guest

    On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy <> wrote:
    >
    > "Jason Zheng" <> wrote in message
    > news:cpvhee$7uh$...
    > > 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
     
    Jp Calderone, Dec 18, 2004
    #1
    1. Advertising

  2. Jp Calderone wrote:

    > On Fri, 17 Dec 2004 18:16:08 -0500, Terry Reedy <> wrote:
    >>
    >> "Jason Zheng" <> wrote in message
    >> news:cpvhee$7uh$...
    >> > 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
     
    Harlin Seritt, Dec 18, 2004
    #2
    1. Advertising

  3. Jp Calderone

    Steve Holden Guest

    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
     
    Steve Holden, Dec 18, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven Knight
    Replies:
    0
    Views:
    1,229
    Steven Knight
    Aug 18, 2004
  2. Jason Zheng

    better lambda support in the future?

    Jason Zheng, Dec 17, 2004, in forum: Python
    Replies:
    31
    Views:
    844
    Antoon Pardon
    Dec 21, 2004
  3. Roman Suzi
    Replies:
    13
    Views:
    629
    Bengt Richter
    Jan 7, 2005
  4. Steve Dogers

    lambda vs non-lambda proc

    Steve Dogers, Mar 30, 2009, in forum: Ruby
    Replies:
    1
    Views:
    202
    Sean O'Halpin
    Mar 30, 2009
  5. Haochen Xie
    Replies:
    4
    Views:
    262
    Haochen Xie
    Mar 17, 2013
Loading...

Share This Page