help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Q: Testing forthe existence of a function


From: Drew Adams
Subject: RE: Q: Testing forthe existence of a function
Date: Tue, 27 Oct 2009 09:49:50 -0700

> > I would like to add a statement of the form
> > (if (defined 'tool-bar-mode) (tool-bar-mode nil))
> 
> It's not the function you should be testing for but the feature  which
> implements it: (if (featurep 'tool-bar) ...)

I disagree. Usually, it is better to test whether the function or variable that
you will use is defined. That provides finer granularity. `featurep' tells you
whether a library that provides a feature with that name has been loaded, but
different versions of libraries can have different sets of defined functions
(and it's even possible for different libraries to provide the same feature).

On the other hand, different libraries can sometimes define functions that have
the same name. In such a case, a `featurep' test can be more helpful than
`fboundp'.

In sum, it helps to know a bit about the function and library in question, and
even whether other libraries are common that might define a function with the
same name.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]