From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Why is booleanp defined this way? Date: Fri, 17 Apr 2015 19:20:44 -0400 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1429313121 19202 80.91.229.3 (17 Apr 2015 23:25:21 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 17 Apr 2015 23:25:21 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 18 01:25:21 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YjFdO-0005bL-KY for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Apr 2015 01:25:18 +0200 Original-Received: from localhost ([::1]:43825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjFdN-0006po-7A for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Apr 2015 19:25:17 -0400 Original-Path: usenet.stanford.edu!news.kjsl.com!us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!barmar.motzarella.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 Injection-Info: barmar.motzarella.org; posting-host="2be9e9f5dd9af768b8861af71b85fc28"; logging-data="25187"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19J0cuQV53SH1tg+k5DGZ3Y" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:6Vm/j2EYNG757Fd7eNlVKenXOX0= Original-Xref: usenet.stanford.edu gnu.emacs.help:211503 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:103785 Archived-At: In article , Marcin Borkowski wrote: > Hi all, > > this is what I found in subr.el: > > ,---- > | (defun booleanp (object) > | "Return t if OBJECT is one of the two canonical boolean values: t or nil. > | Otherwise, return nil." > | (and (memq object '(nil t)) t)) > `---- > > Seemingly, it doesn't make much sense: what is the purpose of saying > > (and (whatever) t) > > instead of just > > (whatever) > > for a predicate? Of course, this "normalizes" any "truthy" value to > "t", but is it really needed for anything (except perhaps being > elegant)? I guess they felt that the result of booleanp should *be* booleanp. :) While it probably doesn't matter when you're using it in a program, since you'll usually be using it as part of a conditional operator (if, cond, when), they might have felt it would be confusing when people used it interactively: (booleanp nil) => (nil t) (booleanp t) => (t) (booleanp something-else) => nil As a general convention, predicates usually just return t or nil, unless there's a useful non-nil value to return when it's true. In the case of memq, returning the tail of the list starting with the match was felt to be useful. But it's hard to see how returning those little lists instead of t would be helpful to anyone calling booleanp. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***