What If Python Replaced Elisp?

Amit Patel amitp at Xenon.Stanford.EDU
Mon Mar 27 16:23:28 EST 2000


  <taashlo at sandia.gov> wrote:
| So I'll start us off:
| 
| Elisp function definitions may be interactive or non-interactive.  If
| interactive, then you can use a string to specify how the parameters
| are obtained from the user (types, prompts, etc.).  How would this be
| done in Python?  (Beginner opinion: I would make all functions
| interactive and use a combination of default arguments and explicit
| parameter checks.  For example, default an argument to None and check
| for this at the beginning of the function, if the argument is None,
| then prompt the user for input.  Is there a better way?)
| 

Other features of Elisp that we'd have to figure out:

Variables can be buffer-local.  (Maybe frame-local, window-local,
too?)

Variables are dynamically scoped.  This may fit in with
buffer-local-ness.

Variables can be set to _become_ buffer local when modified.  I think
this is tied to variables having "default" values.

Many Lisps, including Elisp, have "autoloading" -- where you can
say that function F is available from package P, but it doesn't
actually load package P until you call F.

Elisp lets you define something if it hasn't been defined, or ignore
the statement otherwise.  (defvar)

Elisp lets you unload a module (unload-feature).

Lisp makes it easy to take programs that read/manipulate other
programs.  I suspect this is used in the byte-compile-optimizer but
I'm not sure.  It's also used in various packages to evaluate an
expression in some context .. for example, in font-lock, you can embed
a program into a data structure used to describe what to highlight.
Lisp uses expressions everywhere (no distinction between
statements and expressions), so it's a little easier to embed programs.

Lisp's quoted symbols are used in lots of places, like key/mouse
bindings.  In this context they're used for indirection: you can bind
"tab" to 'indent-line, but the "indent-line" function is looked up
dynamically, so you can redefine it and "tab" will still work (with
the new value).

Elisp uses property lists, where you can associate data with a symbol,
to provide some kind of distributed data definition -- for example,
font-lock mode doesn't want to define python-mode font-locking, but
python-mode doesn't want to depend on font-lock-mode, so
font-lock-mode will read the 'font-lock-defaults property and find
symbol 'python-mode.  Python-mode can put something there for
font-lock-mode to read, but the two don't interact directly.



That's all I can think of right now.


        - Amit



More information about the Python-list mailing list