Let's Talk About Lambda Functions!

John Roth johnroth at ameritech.net
Mon Aug 5 03:39:34 CEST 2002

"Steve Holden" <sholden at holdenweb.com> wrote in message
news:mAb39.240112$724.131601 at atlpnn01.usenetserver.com...
> "John Roth" <johnroth at ameritech.net> wrote ...
> > "Steve Holden" <sholden at holdenweb.com> wrote ...
> [ ... ]
> > > Mostly because anything as complicated as this current proposal is
> > more
> > > complicated than defining a named function and using it the once.
> > Frankly
> > > (IMHO), anything that need this much explanation is unlikely to
> > 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.
> >
> I'm glad it's been helpful.
> > 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.
> >
> ...if we overlook the minor detail that the "indent" token can only
occur at
> the beginning of a line. I don't mean to beat this to death, but in
> for your proposal to work you have to alter the syntax of expressions
> make indentation significant where it currently isn't. That's a) far
> trivial, and b) far from obvious.

Actually, at this point, it _is_ the first token on the line. That just
seems to make it much more obvious what's going on.

For example (and this is the example in the draft PEP on my disk)

x = (
    def (a, b):
        print a
        print b

Note where the def occurs. While we could allow it on the line
following the open paren, it does seem to create a lot of confusion.
It's much
simpler (and clearer) to require it on the next line. That leaves the
function for one-liners, which is entirely appropriate, as well as

John Roth

More information about the Python-list mailing list