all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lawrence Mitchell <wence@gmx.li>
To: bug-gnu-emacs@gnu.org
Subject: bug#7086: `booleanp' return value is multi-valued list
Date: Fri, 24 Sep 2010 10:28:41 +0100	[thread overview]
Message-ID: <pvhpeicjjxrq.fsf@gmx.li> (raw)
In-Reply-To: <AANLkTinm3u=qvJDd4Ncx8pyM0UZ26OzJirzyG3X2JeFn@mail.gmail.com>

MON KEY wrote:
> This one matters. It is the penultimate Emacs lisp predicate.
> It tests for a boolean value yet it returns a list.

Which you can happily dispatch on:

(if (booleanp foo)
    (if (null foo)
        (do-something-if-foo-is-nil)
      (do-something-if-foo-is-t))
  (do-something-if-foo-is-neither-nil-nor-t))

It's hard to see what else is required

[...]

> On Thu, Sep 23, 2010 at 4:12 AM, Eli Zaretskii <eliz@gnu.org> wrote:

[...] MON KEY claims that (funcall (lambda (x) (booleanp x)))
giving an error is somehow problematic.
>> Exactly!  See the above node in the manual.

>> But this has nothing to do with booleanp.

> It has everything to do with it.  These are just the types of
> situations where interrogating a boolean is what is wanted.

What?

(funcall (lambda (x) (1+ x)))
 => (wrong-number-of-arguments (lambda (x) (1+ x)) 0)

(funcall (lambda (x) (booleanp x)))
  => (wrong-number-of-arguments (lambda (x) (booleanp x)) 0)

Calling a function expecting an argument without one is an error,
irrespective of the function involved.

Do you in fact want:

(require 'cl)

(defun* foo (&optional (x nil got-x-p))
  (if got-x-p
      (do-something-if-x-was-an-argument x)
    (do-something-different)))

[...]


-- 
Lawrence Mitchell <wence@gmx.li>






  parent reply	other threads:[~2010-09-24  9:28 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
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 [this message]
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=pvhpeicjjxrq.fsf@gmx.li \
    --to=wence@gmx.li \
    --cc=bug-gnu-emacs@gnu.org \
    /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.