[Python-3000] A plea for anonymous functions
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Nov 17 03:54:31 CET 2006
Talin wrote:
> From my point of view, both 'with' and generator expressions are
> limited, special-case solutions to a general problem - the desire to be
> able to use and manipulate unnamed blocks of code as first-class
> objects.
I don't think it's as simple as that. Back when the with
statement was first being discussed, I suggested that it
should be implemented by passing the body as an anonymous
function. That would have been a very simple way of doing
it, but there were problems, such as what to do if the
body contained break or continue statements. In the end,
Guido rejected the anonymous-function approach, and we
ended up with something that is rather more elaborate.
So we have a situation where there was no syntactical
barrier to treating a code block as an anonymous function,
but we chose not to do so. That seems to cast doubt on
the idea that first-class code blocks would solve all
the problems you suggest they would solve.
--
Greg
More information about the Python-3000
mailing list