Could Emacs be rewritten in Python?

Alexander Schmolck a.schmolck at gmx.net
Sun Apr 6 23:16:05 EDT 2003


Carl Banks <imbosol-1049649076 at aerojockey.com> writes:
> Next three functions are "save-current-buffer", "with-current-buffer",
> and "with-temp-buffer".  These are actually not functions, but special
> forms and macros.  Python has no analogue to these (barring some
> obscure metaclass tricks). 

Care to share the obscure metaclass trick to implement with-* style macros in
python?

> There is one potentially disasterous pitfall you should be aware of.
> Emacs does all kinds of strange things with namespaces.  It uses
> dynamic binding, unlike Python, which uses lexical binding.  Emacs has
> one monolithic global namespace, as opposed to Python, which has an
> organized infrastructure of "global" namespaces, that is, modules.
> Also, Emacs has weird namespaces like buffer local variables.  One
> thing you'll have to do is think about how to sort all these namespace
> issues out.

Yes, these are minor issues (BTW you forgot to mention that emacs also has
separate namespaces for functions/macros and variables (and, in a slightly
different way, lots of other things)).

But luckily enough reimplementing emacs in some "better" programming language
is a common enough computer scientist phantasy that a formal analysis of the
particular hurdles dynamic scope poses has already been done for you (buffer
local variables are also briefly mentioned):

http://citeseer.nj.nec.com/neubauer01down.html

 
> It seems to me that a lot of these issues won't matter much if you
> have a good and consistent strategy for organizing stuff and passing
> parameters around.

:)


alex




More information about the Python-list mailing list