[Top][All Lists]

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

bug#7086: `booleanp' return value is multi-valued list

Subject: bug#7086: `booleanp' return value is multi-valued list
Date: Thu, 23 Sep 2010 00:22:18 -0400

On Wed, Sep 22, 2010 at 6:35 PM, Juanma Barranquero <address@hidden> wrote:
> On Wed, Sep 22, 2010 at 23:58, MON KEY <address@hidden> 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.


reply via email to

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