Let's Talk About Lambda Functions!

John Roth johnroth at ameritech.net
Tue Aug 6 15:02:34 CEST 2002

"Greg Ewing" <see_reply_address at something.invalid> wrote in message
news:3D4F2EB5.8090603 at something.invalid...
> John Roth wrote:
> > Wouddn't that make the parser more complex, however?
> > The dedent is what closes the structure normally, this would
> > add a special case rule.
> Actually, it would be done in the lexer (which is what
> does the final dedenting at the end of the file).
> The lexer already has to keep track of whether it's
> inside nested parentheses, and ignore indentation.
> For this, it would have to notice when a "def"
> occurred inside the parens and start generating
> INDENT/DEDENT tokens again. When it got to the
> closing paren, it would emit enough DEDENTs to
> get back to the level it was at when the parens
> were opened.

So what you're saying is that the lexer would have
to recognize the token sequence '(' 'def' and
insert an INDENT token, as well as change state.

> Yes, it would be more complicated, but implementing
> this at all will add some complexity somewhere.

Doesn't seem like it's too horrible to contemplate.

John Roth

More information about the Python-list mailing list