[Top][All Lists]

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

RE: How to avoid loading file when just testing if function

From: Drew Adams
Subject: RE: How to avoid loading file when just testing if function
Date: Mon, 2 Apr 2012 08:00:11 -0700

FWIW - I believe that someone else has already pointed out that the test for
whether a symbol is bound to a function and not just to an autoloaded object
(which is a promise of loading a function) is this:

(defun funp (symbol)
  "SYMBOL's function definition is non-void and not an autoload object."
  (and (fboundp symbol)
       (not (eq 'autoload (car-safe (symbol-function symbol))

Such a function should perhaps be predefined for Emacs, but it is not.  There
are at least three things to keep in mind when testing whether a symbol is
defined as an Emacs-Lisp "function", depending on what you need: `fboundp',
`functionp', and the above test (`funp').

Other tests are sometimes relevant too: `subrp' and `byte-code-functionp'.  And
remember that `functionp' returns non-nil also for some non-symbols: lambda
forms, closures, and byte-code functions.  And `fboundp' returns non-nil for
some non-functions such as macros and special forms.

Then there's the fact that a Lisp "function" does not necessarily implement a
(mathematical) function...  Yes, the terminology can be confusing.  The Elisp
manual is your friend, as is the Emacs source code.

reply via email to

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