On Fri, 2004-04-30 at 09:30, Barry Warsaw wrote: > On Fri, 2004-04-30 at 09:07, Armin Rigo wrote: > > > This looks (a) cool and (b) a complete hack that nobody should be allowed to > > do without messing with sys._getframe(). > > It reminds me a little bit of the dynamic binding in Emacs lisp. As > incredibly useful as that is sometimes, it's a disgusting hack. :) The funny thing is that it's the result of a static scoping discipline rather than dynamic scoping. What's funny about it has more to do with side-effects that scoping rules. If the x_square function was returned out of its defining block, there would be no way to rebind x and it would not be possible to define a variable x local to the caller that would affect it. Put another way, it's possible to reason statically about what binding x will use when x_square() is called. It's the same technique you would use to write an accumulator generator (that is, a function that returns accumulator functions). See the appendix of Paul Graham's essay: http://www.paulgraham.com/icad.html Jeremy PS I do owe everyone a PEP on the subject of re-binding.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4