> >>>>> Bruno Daniel writes:
> Bruno> can I add new Emacs Primitives in C code to Emacs without
> Bruno> recompiling the whole Emacs program?
> What is a "primitive"? You can add everything you like to Emacs in
> Lisp without having to recompile anything.
A "primitive" is a popular name for a routine that must be written in
C, because of a number of possible reasons. Either it must access the
system resources that are accessible only through C on a given system,
or it must run fast enough to make the interpreter overhead
unacceptable, or it must extend the existing Emacs internals, which
are implemented in C themselves. Three examples of routines that are
(and should be) written in C follow:
1) load-average, current-time, ...
The `load-average' function calls the `getloadavg' C function. If
this functionality didn't exist, on most systems it would be
impossible to write a Lisp function to simulate `load-average' fully.
2) mapcar, format, ...
A function like `mapcar' could be well written in Lisp (it's trivial
to loop through a list and apply the function to CARs), but it is
written in C because of speed. `mapcar' is considered a low-level
function, and it's good to have it in C, without the interpreter
3) eq, car, ...
These functions must be written in C, because they are used to
implement the basic functionality of the Lisp interpreter, which is
itself written in C.
So, you cannot add "everything you like" to Emacs in Lisp. There are
at least three cases when you must extend Emacs C base in order to
provide new Lisp functions, or improve the existing ones to get more
For cases #1 and #2, dynamical loading might improve the usability of
Emacs significantly. It's another question whether such a direction
is a good way to go. Emacs developers seem to have chosen a different
(and IMHO better, in the long term) path.
I *hate* the word "plug-in". :-)
You'll notice that perl is not itself written in Perl.
-- The Perl FAQ