GNU bug report logs -
#7086
`booleanp' return value is multi-valued list
Previous Next
Reported by: MON KEY <monkey <at> sandpframing.com>
Date: Wed, 22 Sep 2010 21:56:01 UTC
Severity: minor
Tags: notabug
Done: Chong Yidong <cyd <at> stupidchicken.com>
Bug is archived. No further changes may be made.
Full log
Message #14 received at 7086 <at> debbugs.gnu.org (full text, mbox):
On Wed, Sep 22, 2010 at 6:35 PM, Juanma Barranquero <lekktu <at> gmail.com> wrote:
> On Wed, Sep 22, 2010 at 23:58, MON KEY <monkey <at> sandpframing.com> wrote:
>
>> "Return non-`nil' if OBJECT is one of the two canonical boolean
>> values: `t' or `nil'."
>>
>> It should be documented both in the manual and the docstring of `booleanp' that
>> its return value is a list.
>
> Why? It is a type predicate. If anything, it should be changed to
> return t or nil,
I'm pretty sure returning a single value is NTRT and can only generate
confusion e.g.:
(booleanp (booleanp "not-a-boolean")) ;=> t
What I would suggest is the following behavior:
(booleanp t)
;=> (t t)
(booleanp nil)
;=> (nil t)
(booleanp "not-a-boolean")
;=> (nil nil)
Returning a two element list on success shares some similarity with
Common Lisp's multiple values which seem pertinent for special cases
like this one in that there is provision for reflection that is hard
to obtain with a uni-valued return, e.g. Right now if I ask:
(let ((query-truth (eq 8 3)))
(car (booleanp query-truth)))
;=> nil
it is hard to know if the thing being queried of was indeed a boolean.
Whereas with a two element proper list:
(let ((query-truth (eq 8 3)))
(and (cadr (booleanp query-truth))
(not (car (booleanp query-truth)))))
;=> t
We can be sure we got a boolean and that it was nil.
--
/s_P\
This bug report was last modified 14 years and 292 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.