Could Emacs be rewritten in Python?

Alexander Schmolck a.schmolck at gmx.net
Tue Apr 8 12:53:45 EDT 2003


Kim Petersen <kp at kyborg.dk> writes:

> Alexander Schmolck wrote:
> > Kim Petersen <kp at kyborg.dk> writes:
>  >> (snip)
> >>function in elisp - do a shallow copy of local variable space (dictionary) and
> >>send it as the local vars - you can safely throw away the dict after function
> >>returns).
> > Ahem, there are several thousand variables kicking about in global in emacs,
> > you want to copy them all for each function call?
> 
> look above - *Local* variable space ... globals stay globals.

Maybe we have a misunderstanding. 

I thought in your scheme every call to a lisp function foo (from python *or*
another lisp function) is to be implemented by making a copy of the locals and
passing it to foo and this copy is discarded after return. If so, this won't
work (because foo can mess with its callers *locals*; also globals *don't*
stay globals -- a let binding of a global name means it can no longer be
globally modified further up the call tree).

A better example to clarify:

(defun foo()
  (message "when foo is called folding is: %s" case-fold-search)
  (setq case-fold-search :evil))
(defun bar()
  (message "when bar is called folding is: %s" case-fold-search)
  (let ((case-fold-search t))
    (foo)
    (message "what did foo do to folding? %s!" case-fold-search))
  (message "bar's last folding is: %s again" case-fold-search))
(defun quux()
  (message "before bar:%s" case-fold-search)
  (bar)
  (message "after bar:%s" case-fold-search))
(quux)


before bar:nil
when bar is called folding is: nil
when foo is called folding is: t
what did foo do to folding? :evil! ;; !!!
bar's last folding is: t again 
after bar:nil

Tell me if you think this would work, too and I'll just reread your message.


'as




More information about the Python-list mailing list