Let's Talk About Lambda Functions!

Greg Ewing see_reply_address at something.invalid
Mon Aug 5 22:04:37 EDT 2002


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.

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


-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list