From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Q: Testing forthe existence of a function Date: Tue, 27 Oct 2009 09:49:50 -0700 Message-ID: <36E8CB7B010C489883A781568F0156AE@us.oracle.com> References: <26077455.post@talk.nabble.com> <87my3cre4o.fsf@ukdev-lin-grc.uk.rd.tandberg.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1256662321 23497 80.91.229.12 (27 Oct 2009 16:52:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Oct 2009 16:52:01 +0000 (UTC) To: "'Giles Chamberlin'" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 27 17:51:54 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N2pGt-0000x4-1s for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Oct 2009 17:51:47 +0100 Original-Received: from localhost ([127.0.0.1]:40257 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2pGs-0005v8-KO for geh-help-gnu-emacs@m.gmane.org; Tue, 27 Oct 2009 12:51:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2pGG-0005jv-Aw for help-gnu-emacs@gnu.org; Tue, 27 Oct 2009 12:51:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2pGB-0005gb-Av for help-gnu-emacs@gnu.org; Tue, 27 Oct 2009 12:51:07 -0400 Original-Received: from [199.232.76.173] (port=41891 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2pGB-0005gP-2e for help-gnu-emacs@gnu.org; Tue, 27 Oct 2009 12:51:03 -0400 Original-Received: from rcsinet12.oracle.com ([148.87.113.124]:22511 helo=rgminet12.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N2pGA-0004ZG-L4 for help-gnu-emacs@gnu.org; Tue, 27 Oct 2009 12:51:02 -0400 Original-Received: from rgminet13.oracle.com (rcsinet13.oracle.com [148.87.113.125]) by rgminet12.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n9RGoYjL009915 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Oct 2009 16:50:35 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by rgminet13.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n9R80ZDc019744; Tue, 27 Oct 2009 16:51:37 GMT Original-Received: from abhmt021.oracle.com by acsmt354.oracle.com with ESMTP id 20652047481256662197; Tue, 27 Oct 2009 09:49:57 -0700 Original-Received: from dradamslap1 (/24.5.184.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 27 Oct 2009 09:49:57 -0700 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcpXJFdiUWpz+05PSlKmiyAFtz3BSwAAIKFw In-Reply-To: <87my3cre4o.fsf@ukdev-lin-grc.uk.rd.tandberg.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Source-IP: acsmt355.oracle.com [141.146.40.155] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090204.4AE724F2.0022:SCFMA4539814,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69282 Archived-At: > > 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.