Could Emacs be rewritten in Python?

Kim Petersen kp at
Tue Apr 8 08:11:02 CEST 2003

Alexander Schmolck wrote:
> Kim Petersen <kp at> 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
> 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.

> How do your propose to handle the following efficiently:
> (defun foo()
>   (message "when foo is called folding is: %s" case-fold-search))
> (defun bar()
>   (message "when bar is called folding is: %s" case-fold-search)
>   (let ((case-fold-search t))
>     (foo))
>   (message "now folding is: %s again" case-fold-search))
> (bar)

let me propose the following:

    * in python a function (lispname) is called as follows:
        def lispfun(arg0,arg1,...,rest,locals,buffer):

        - arg0,arg1 is filled with the first n arguments from cons,
          rest is filled with the rest of the cons:

          def lispadd(rest,locals,buffer): pass
          def cons(car,cdr,locals,buffer): pass
          def car(cons,locals,buffer): pass
          def while(expr,body,locals,buffer): pass

        - locals is the local variable space
        - buffer is the buffer variable space
        - (globals could be defined - but no need)

    * now (let ...) should be easy to handle... in either of two ways.
         1. make dictionary copy of locals
         2. push and pop old definitions from a variable stack.

> when bar is called folding is: nil
> when foo is called folding is: t
> now folding is: nil again
> alex

Med Venlig Hilsen / Regards

Kim Petersen - Kyborg A/S
IT - Innovationshuset
Havneparken 2
7100 Vejle
Tlf. +4576408183 || Fax. +4576408188

More information about the Python-list mailing list