Could Emacs be rewritten in Python?

Greg Ewing (using ckea25d02 at
Wed Apr 9 02:51:43 CEST 2003

Skip Montanaro wrote:
> Look again.  In Elisp, when foo() looks up the value of case-fold-search it
> will find the value defined in the let statement inside bar() because it's
> lexically scoped  (looks up the call chain for values).

Your terminology is confused -- that's *dynamic* scoping.

> If this was Python,
> the reference to case-fold-search in foo() would be resolved at the global
> scope because Python is statically scoped (looks in locals, globals, then
> builtins only

*This* is called lexical scoping (since the scope is determined
by where the code is written). (Although calling it "static"
is correct too, since it's not dynamic.)

 > ignoring nested functions which this case doesn't involve).

In recent Pythons, this is no longer true -- intermediate
lexical scopes are searched, too (although only for _reading_,
just to keep things Pythonically perverse.:-)

Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand

More information about the Python-list mailing list