Could Emacs be rewritten in Python?

Carl Banks imbosol-1050454138 at aerojockey.com
Tue Apr 15 21:47:23 EDT 2003


Alexander Schmolck wrote:
> 
> 
> Carl Banks <imbosol-1050288268 at aerojockey.com> writes:
> 
> Firstly:
> 
>> > Have you had traumatic childhood experiences with early perl or lisp
>> > dialects?  :)
>> 
>> Yes
> 
> OK, let's try this. Just consider for a moment the following possibility:
> 
>  THERE IS NOT A *SINGLE* DRAWBACK TO DYNAMICALLY SCOPED *GLOBALS*.

I don't think you're giving me enough credit here.

Fully aware that lexically-scoped local variables will still exist
alongside dynamically scoped variables, and need not be confused with
each other, I simply do not want to see dyanamic scoping at all.

The disadvantages of dynamic scoping are there, completely
irrespective of lexical variables.  Labeling it a "global" doesn't
make these problems go away (as if there were a even useful
distinction between dynamic globals and locals).  The mere possibility
of temporarily rebinding a variable is a wart.

And, frankly, the legitimate uses of temporarily rebound globals are
very rare, otherwise you're doing something wrong.  The right way to
pass parameters is the argument list.

Yes!  I fully admit that there are practical reasons to not pass
parameters as arguments, and occasionally a dynamically scoped
variable can do exactly what you want.  But it comes with a completely
unexcusable cost, namely: an inferior, bug-prone scoping system; the
tendency for people to lazily use dynamically scoped variables when
they should be passing them as parameters; add complexity and
confusion to the language.

Also, dynamic scoping violates a chunk of the Python Zen: Explicit is
better than implicit.  (You should pass parameters explicitly.)
Simple is better than complex.  (One scoping strategy is simpler than
two.)  Special cases aren't special enough to break the rules.  (Valid
uses for dyanmic scoping are special cases and should not break the
rule of lexical scoping.)

All this, when you can get the same effect in a thread-safe way with
try ... finally.


Forget it.  The benefit is miniscule, work-around-able, and the
drawbacks are enormous.  Dyanmic scoping is just a bad idea that needs
to die.


-- 
CARL BANKS




More information about the Python-list mailing list