At 11:54 PM 5/3/05 +0200, BJörn Lindqvist wrote: >It seems like the possibilities are endless. Maybe too endless? >Because this new feature is so similar to anonymous functions, but is >not quite anonymous functions, so why not introduce anonymous >functions instead, that could make all the things block can, and more? >But as I said, I'm misunderstanding something.
Anonymous functions can't rebind variables in their enclosing function. It could be argued that it's better to fix this, rather than inventing a new macro-like facility, but I don't know how such a rebinding facility could preserve readability as well as PEP 340 does. Also, many of your examples are indeed improvements over calling a function that takes a function. The block syntax provides a guarantee that the block will be executed immediately or not at all. Once you are past the block suite in the code, you know it will not be re-executed, because no reference to it is ever held by the called function. You do not have this same guarantee when you see a function-taking-function being invoked. So, a block suite tells you that the control flow is more-or-less linear, whereas a function definition raises the question of *when* that function will be executed, and whether you have exhaustive knowledge of the possible places from which it may be called. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com