>>>> "Valdis" == Valdis Kletnieks
<Valdis.Kletnieks(a)vt.edu> writes:
What's the politically correct way to write Lisp code that does something
like this:
Valdis> (maybe-require 'foo)
Valdis> (if (feature-p 'foo-feature1) (foo-do-optional))
Modern Emacsen (I think that actually means XEmacs > 21.4, or use
APEL) have a third argument NOERROR for `require'. `featurep' is
really just `memq', so you should have no problems with `foo-feature1'
not being present.
(require 'foo nil t)
(if (feature-p 'foo-feature1) (foo-do-optional))
If you want portability, substitute
(condition-case nil (require 'foo) (file-error nil))
for the require.
Valdis> but avoid 3 gazillion complaints about undefined
Valdis> foo-feature and foo-optional if you try to byte-compile it
Valdis> in an environment lacking foo?
I think you _should_ get a warning. However, if you really want to
turn it off, put
(byte-compiler-options (warnings (- unresolved)))
at the top of the library. (`byte-compiler-options' is a macro, and
has a definitive docstring.) In 21.5 it's possible to do this kind of
thing on a very fine-grained basis (thanks (?) to Ben), but I haven't
messed with that so I can't even tell you what the API is.
Patch to lispref coming up....
--
Institute of Policy and Planning Sciences
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
My nostalgia for Icon makes me forget about any of the bad things. I don't
have much nostalgia for Perl, so its faults I remember. Scott Gilbert c.l.py