[Python-Dev] Let's just *keep* lambda

Paul Moore p.f.moore at gmail.com
Tue Feb 7 10:56:31 CET 2006


On 2/7/06, Brett Cannon <brett at python.org> wrote:
> On 2/5/06, Guido van Rossum <guido at python.org> wrote:
> > After so many attempts to come up with an alternative for lambda,
> > perhaps we should admit defeat. I've not had the time to follow the
> > most recent rounds, but I propose that we keep lambda, so as to stop
> > wasting everybody's talent and time on an impossible quest.
>
> I have been thinking about this, and I have to say I am a little
> disappointed (-0 disappointed, not -1 disappointed).  I honestly
> bought the argument for removing lambda.  And I think that a deferred
> object would help with one of lambda's biggest uses and made its loss
> totally reasonable.

I'm not 100% sure what you mean here, but as far as my understanding
goes, current lambda *is* a "deferred object" (or at least a "deferred
expression", which may not be quite what you mean...)

> But I know that everyone and their email client is against me on this
> one, so I am not going to really try to tear into this.  But I do
> think that lambda needs a renaming.

I agree with this. The *name* "lambda" is a wart, even if the deferred
expression feature isn't. My preference is to simply replace the
keyword lambda with a keyword "expr" (or if that's not acceptable
because there's too much prior use of expr as a variable name, then
maybe "expression" - but that's starting to get a bit long).

> Speaking as someone who still
> forgets that Python's lambda is not the same as those found in
> functional languages,

Well, only in the sense that Python's *expressions* are not the same
as those found in functional languages (ie, Python has statements
which are not expressions). But I see your point - and I strongly
object to going the other way and extending lambda/expr to allow
statements or suites.

> I would much rather have it named 'expr' or
> 'expression' or something that is more inline with its abilities then
> with a name taken for CS historical reasons.  This ain't for father's
> lambda and thus shouldn't be named so.

Agreed. But if "expr" isn't acceptable, I don't like the other common
suggestion of reusing "def". It's not a definition, nor is it "like an
anonymous function" (the lack of support for statements/suites being
the key difference).

> Then again, Guido did say he "should", not that he "did" admit defeat.  =)

OTOH, he was trying to stop endless the discussion... :-)

Paul.


More information about the Python-Dev mailing list