unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: David Kastrup <dak@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: (list) and '(list)
Date: Fri, 27 Apr 2007 12:39:00 +0200	[thread overview]
Message-ID: <85k5vygkzf.fsf@lola.goethe.zz> (raw)
In-Reply-To: mailman.2588.1177669955.7795.help-gnu-emacs@gnu.org

Kai Grossjohann <kai@emptydomain.de> writes:

> Perhaps what you want is to write a special form yourself?  That
> can't be done in a strict sense, but you can use macros to
> approximate the effect.
>
> For example, to reverse the condition of `if' (proof of concept only,
> not production code):
>
> (defmacro ifnot (test no yes)
>   (if (not test) no yes))
>
> Does that help?

You are confusing `defmacro' with `defsubst'.  What you wrote above
will have the effect of _compiling_ to no if the _unevaluated_ first
argument is anything but nil, and to yes if it is nil.

That is:
(ifnot blurb "x" "y")
will (at compile time already) be resolved to "x", regardless whether
blurb is currently (or at run time) nil.  In fact, the _value_ of
blurb is _never_ consulted.  To compile to "y", use one of the
following:
(ifnot nil "x" "y")
(ifnot () "x" "y")
What will _not_ work is
(ifnot '() "x" "y")
Because then test will be set to (quote nil) when the test is done,
which is not nil, even though it evaluates to nil.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

  parent reply	other threads:[~2007-04-27 10:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-26 15:17 (list) and '(list) A Soare
2007-04-27 10:25 ` Kai Grossjohann
     [not found] ` <mailman.2588.1177669955.7795.help-gnu-emacs@gnu.org>
2007-04-27 10:39   ` David Kastrup [this message]
2007-04-27 11:05   ` Pascal Bourguignon
2007-04-30 12:49     ` Kai Grossjohann
     [not found] <mailman.2557.1177600988.7795.help-gnu-emacs@gnu.org>
2007-04-26 21:55 ` Pascal Bourguignon
2007-04-27  0:58 ` Tim X
  -- strict thread matches above, loose matches on Subject: below --
2007-04-27 10:37 A Soare
2007-04-30 18:15 A Soare
2007-04-30 18:53 A Soare

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=85k5vygkzf.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=help-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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).