all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: MON KEY <monkey@sandpframing.com>
To: Juanma Barranquero <lekktu@gmail.com>
Cc: kevin.d.rodgers@gmail.com, 7086@debbugs.gnu.org
Subject: bug#7086: `booleanp' return value is multi-valued list
Date: Thu, 23 Sep 2010 00:22:18 -0400	[thread overview]
Message-ID: <AANLkTinf6unJGZX4bmXta1y-3AC5yJK5rH4vsbqMjeBc@mail.gmail.com> (raw)
In-Reply-To: <AANLkTim5_1H+hiUHP9vi4gszpvm-vydugvjA9k7HR6fH@mail.gmail.com>

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





  parent reply	other threads:[~2010-09-23  4:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-22 21:58 bug#7086: `booleanp' return value is multi-valued list MON KEY
2010-09-22 22:35 ` Juanma Barranquero
2010-09-23  2:06   ` Kevin Rodgers
2010-09-23 10:29     ` Juanma Barranquero
2010-10-03  1:11     ` Chong Yidong
2010-09-23  4:22   ` MON KEY [this message]
2010-09-23 10:31     ` Juanma Barranquero
2010-09-23  8:12 ` Eli Zaretskii
2010-09-24  6:41   ` MON KEY
2010-09-24  8:48     ` Juanma Barranquero
2010-09-24  9:28     ` Lawrence Mitchell
2010-09-24 22:00 ` MON KEY
2010-09-25  9:18   ` Juanma Barranquero

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

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

  git send-email \
    --in-reply-to=AANLkTinf6unJGZX4bmXta1y-3AC5yJK5rH4vsbqMjeBc@mail.gmail.com \
    --to=monkey@sandpframing.com \
    --cc=7086@debbugs.gnu.org \
    --cc=kevin.d.rodgers@gmail.com \
    --cc=lekktu@gmail.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.