Securing a future for anonymous functions in Python
donn at u.washington.edu
Fri Jan 7 14:35:54 EST 2005
In article <10trupr9cmrtqd0 at corp.supernews.com>,
Jeff Shannon <jeff at ccvcorp.com> wrote:
> Hm, I should have been more clear that I'm inferring this from things
> that others have said about lambdas in other languages; I'm sadly
> rather language-deficient (especially as regards *worthwhile*
> languages) myself. This particular impression was formed from a
> recent-ish thread about lambdas....
> (line-wrap's gonna mangle that, but it's all one line...)
> Looking back, I see that I've mis-stated what I'd originally
> concluded, and that my original conclusion was a bit questionable to
> begin with. In the referenced thread, it was the O.P.'s assertion
> that lambdas made higher-order and dynamic functions possible. From
> this, I inferred (possibly incorrectly) a different relationship
> between functions and lambdas in other (static) languages than exists
> in Python.
One could easily be led astray by that post. He may be right
in some literal sense about "the true beauty of lambda function",
inasmuch as beauty is in the eye of the beholder, but in practical
terms, functions are functions.
I took this up on comp.lang.functional some time back. I rewrote
a well known piece of Haskell (State monad), moving functions from
lambda expressions to named function declarations in a "where"
clause and I think undisputably making it easier to understand,
and I asserted that this is representative of the general case -
lambda is a non-essential feature in Haskell. I don't know if
anyone was persuaded, but I didn't see any counter-arguments either.
But of course even if I'm right about that, it doesn't mean the
feature should be stripped from Haskell, that would be an atrocity.
It may not be essential, but it's eminently useful and natural.
Is it useful and natural in Python? Is it worth breaking code over?
Why do we even bother to discuss this here? There aren't good answers
to those questions.
Donn Cave, donn at u.washington.edu
More information about the Python-list