What does PYTHON fix?

François Pinard pinard at iro.umontreal.ca
Mon Jan 21 10:49:00 EST 2002


[Paul Foley]

Let me reply to the Python list as well: other opinions might pop up.
We should rather discuss Pymacs here.  I'm sure `vi' people would accept
bearing with us :-).  Moreover, `vi' Python extensibility might fertilise
Pymacs (or vice-versa, who knows!).

> it says that M-x pymacs-load RET os RET will cause M-: (os-getcwd) to call
> the Python os.getcwd function.  The naming scheme seems quite dangerous --
> can easily smash existing names, etc.; I think you should make it intern
> a symbol named "py:os-getcwd" instead (a lot of Common Lisp-related
> packages for Emacs use names like that, to look like a CL package prefix).

`pymacs-load' has an extra argument for setting the prefix, if the user
wants to.  Most Emacs Lisp packages do not use `PREFIX:' as a convention,
and I wanted that Python extensions look no different.  In particular,
there is no need to force the user into constantly remembering and writing
that things are going through Pymacs, it is on purpose that I avoided this.

> Second suggestion: rename pymacs-load to py:import; similarly for whatever
> other functions you export (pymacs-eval and pymacs-apply, apparently).

`pymacs-eval' and `pymacs-apply' are reminiscent of the Emacs Lisp functions,
not really the Python ones.  So is `pymacs-load'.  It is surely debatable
about if we should give the Emacs side an Emacsish or a Pythonish aspect.

    The goals are to write "naturally" in both languages, debug with ease,
    fall back gracefully on errors, and allow full cross-recursivity.

The current choice comes from the first goal, I think.  We could surely do
better, like integrating Pymacs with Emacs auto-load or `require', but I
did not succeed in doing this correctly, yet.  Currently, `pymacs-load'
does either a Python `import' or a Python `reload', because Emacs Lisp
`load' does not try to spare the reloading as Python does.

> I don't like that (pymacs-load "os") defines os-getcwd; in Python,
> it only puts "os" in the local namespace -- something like (os getcwd)
> is a better way to say "os.getcwd" in Lisp

While Python is clean on namespaces, Emacs is rather a big pollution.  I did
not try to change that.  Even if I routinely do things like you suggest in
other, unrelated projects, Pymacs tries to stick with Emacs Lisp methods, I'm
not trying to use it as a vector to introduce radically new ideas or methods.

> [...] your README file says various things about "Lisp" which are
> specific to Emacs Lisp [e.g., "The rigidity of LISP vectors is such
> that people do not resort to vectors unless there is a speed issue,
> so in real LISP practice, vectors are used rather parsimoniously.",
> which is certainly not true in Common Lisp, for example]; [...] I think
> you should explicitly say "Emacs Lisp" everywhere by default, and just
> "Lisp" only for things that are universally true.

Reasonable and fair.  I'll revise that aspect.  Thanks for the suggestion.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list