Could Emacs be rewritten in Python?

Alexander Schmolck a.schmolck at gmx.net
Tue Apr 15 20:03:11 EDT 2003


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*.

Shocking, isn't it? And quite possibly wrong, but let's just forget about that
for the moment, OK? I really think that discussion (and replying to your
posts) is unduly complicated by the fact that you (maybe understandably) seem
to suffer some trauma induced kneejerk reflex.

As I tried to show (unsuccessfully it seems) in my last post, I see no reason
why dynamically scoped globals should in any way more error prone than the
current globals (or require "defensive naming schemes"). OK, let's pretend
there are no packages or classes and that:

  global foo 

declares a *dynamically scoped* variable. No variable in a function that
hasn't got such a declaration, repeat after me, *will ever be dynamically
scoped* -- you can *always* tell by just looking at a function itself, without
context, what the scope of its variables is. No difference for the worse
compared to python's current scheme, right? That's because it still is exactly
the same, up to now. OK, so how do we get the funky (let ((*foo* 3)) ...)
style shadowing? Or how do we introduce a non-global dynamically scoped
variable?. Simply with:

  global foo = 3 # shadows foo (or introduces a new dynamically scoped
                 # variable only visible to callees, and *ONLY* if those
                 # callees contain a ``global foo`` or ``global foo=...``
                 # statement)

so in summary:
  
  foo = 3       # lexical

  global foo    # declares dynamically scoped variable foo (if it doesn't
                # exist, it is created a global scope), pretty much like 'old'
                # global
 
  global foo=3  # shadows foo or declares and binds 3 to it

Maybe this is stupid and maybe it doesn't work and no I haven't thought deeply
about packages and classes so far (which as Beni already mentioned seem to
render a literal mapping of CL's approach unattractive) but this is what I
proposed as an illustration in my last posting and it would clearly seem to
contradict your claim that "you can't tell what it is" (you're right to say
that you can't tell "who set it", but neither of course can you with current
globals, so I have difficulties seeing your point there).

'as




More information about the Python-list mailing list