I think there are four cases:
1. It's something required for correct bytecompilation
2. It's something required at run time
3. It's a feature that can be taken advantage of at run time but is not
required to work.
4. If the user has loaded it, then we'll use it (use ``(featurep)'').
``(require x)'' use to be sufficient for all those probably because
there used to be far fewer independently maintained but still
cooperating lisp modules and almost all the lisp modules got included
in a distribution.
As an example, when I started the package-get stuff, I thought the
'require was for run time dependency (not even thinking about compile
time). Steve thought it was for compile time. The result is that
even though you may not use a package, it still gets downloaded if it
is needed at compile time.
I'd suggest doing something like:
1. (defun require-at-compile (symbol &optional filename)
(eval-when-compile (require symbol filename)))
2. ``(require)'' is considered the "user" level option since that is
what most people would have in their .emacs. This also handles
modules that require something at run time.
3. (defun try-feature (symbol &optional filename)
(if (featurep symbol)
symbol
(setq filename (or filename (symbol-name symbol)))
(if (load filename t)
symbol
nil)))
4. ``(featurep)''
Note that a given module may do:
(require-at-compile 'x)
(try-feature 'x)
or
(require-at-compile 'x)
(require 'x)
--pete
Show replies by date