unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Giles Chamberlin'" <giles.chamberlin@tandberg.com>,
	<help-gnu-emacs@gnu.org>
Subject: RE: Q: Testing forthe existence of a function
Date: Tue, 27 Oct 2009 09:49:50 -0700	[thread overview]
Message-ID: <36E8CB7B010C489883A781568F0156AE@us.oracle.com> (raw)
In-Reply-To: <87my3cre4o.fsf@ukdev-lin-grc.uk.rd.tandberg.com>

> > 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	other threads:[~2009-10-27 16:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27 13:11 Q: Testing forthe existence of a function grkuntzmd
2009-10-27 16:32 ` Giles Chamberlin
2009-10-27 16:49   ` Drew Adams [this message]
2009-10-27 17:06     ` Giles Chamberlin
2009-10-27 16:44 ` Drew Adams
     [not found] ` <mailman.9565.1256661618.2239.help-gnu-emacs@gnu.org>
2009-10-27 19:08   ` Q: " Ilya Zakharevich
     [not found] <mailman.9564.1256660727.2239.help-gnu-emacs@gnu.org>
2009-10-27 16:41 ` Colin S. Miller
2009-10-27 17:43   ` grkuntzmd
     [not found]   ` <mailman.9573.1256665424.2239.help-gnu-emacs@gnu.org>
2009-10-27 17:57     ` Colin S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36E8CB7B010C489883A781568F0156AE@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=giles.chamberlin@tandberg.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).