Let's Talk About Lambda Functions!

John Roth johnroth at ameritech.net
Sat Aug 3 23:37:43 CEST 2002

"Steve Holden" <sholden at holdenweb.com> wrote in message
news:8eR29.216536$724.70821 at atlpnn01.usenetserver.com...
> "John Roth" <johnroth at ameritech.net> wrote in message
> news:uke7hvgvchhm30 at news.supernews.com...
> >
> > "Daniel Fackrell" <unlearned at DELETETHIS.learn2think.org> wrote in
> > message news:3d46c6a2$1_1 at hpb10302.boi.hp.com...
> [ how to indent an anonymous function ]
> > Does this make sense?
> >
> So, are you proposing to alter the syntax for expressions?
> > >
> > > lambda in its current form does okay in cases like this.  As an
> > expression
> > > it does not require indentation for anything, but it is also not
> > allowed to
> > > execute statements.
> >
> Which is where we came in.
> > Well, yes. And lambda generally does quite well for short functions.
> > The idea that inline functions should be short has a great number of
> > adherents.
> >
> Mostly because anything as complicated as this current proposal is
> complicated than defining a named function and using it the once.
> (IMHO), anything that need this much explanation is unlikely to find
its way
> into Python.

Taking account of Tim Peter's comments on 7/29, I think you're
right that Guido is unlikely to approve it. Nontheless, it's been an
interesting conversation to get my head straight on how it should
look in Python, if it was ever approved.

And at this point, it's incredibly simple, not complicated. When the
compiler sees the token sequence: 'left paren,' 'indent,' 'def' it
shifts to compiling an anonymous function, including the indentation
rules. When the function ends, it shifts back to whatever it was
doing before. I fail to see what is complicated about that.

The actual implementation needs to take care of those messy details
of real world syntax, but it's still not complicated.

John Roth
> regards
> ----------------------------------------------------------------------
> Steve Holden                                 http://www.holdenweb.com/
> Python Web Programming                http://pydish.holdenweb.com/pwp/
> ----------------------------------------------------------------------

More information about the Python-list mailing list