unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: "Garreau, Alexandre" <galex-713@galex-713.eu>
Cc: help-gnu-emacs@gnu.org
Subject: RE: `when' vs. `and' / `unless' vs `or'
Date: Tue, 16 Oct 2018 16:21:06 -0700 (PDT)	[thread overview]
Message-ID: <ad2508c1-69ae-40eb-a039-48a3fb2503af@default> (raw)
In-Reply-To: <87zhvdldoh.fsf@portable.galex-713.eu>

> Okay, so what about when you care about the result, but absolutely not
> about the return value of the condition?
> 
> (unless cond body) vs (or cond body) -> `or' might imply you might want
> to return cond.

I don't understand the question. I use (or ...) when I want to return
the value of a disjunction, where that value, if non-nil, might be
any non-nil Lisp value. If (or cond body) returns cond then it's
because cond is non-nil? What's the question? (And there is no
"cond" as in condition versus "body" as in body. `or' just returns
the first non-nil arg, or nil if none is non-nil.)

> > I use `and' or `or' when the return value is significant.
> > (With `not' as needed.)
> >
> > I use `if' when the true part is a single sexp. If necessary,
> > to respect this I flip the true and false parts (negating the
> > condition).
> 
> So unless it is simple, you always write your big-conditions if as an
> imbrication of both `or' and `and'? isn’t this actually less easy to
> understand (even if easier to read with indentation)?

Dunno what you mean. Isn't what less easy to understand than
what? What's a "big-condition"?

I use `if' when the code cares about the return value, just like
`or' and `and'. If the code doesn't care about the return value,
and if there is only one condition, then I use `when' or `unless'.



  reply	other threads:[~2018-10-16 23:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16 21:05 `when' vs. `and' / `unless' vs `or' Garreau, Alexandre
2018-10-16 22:13 ` Drew Adams
2018-10-16 22:38   ` Garreau, Alexandre
2018-10-16 23:21     ` Drew Adams [this message]
2018-10-17  0:02       ` Garreau, Alexandre
2018-10-17  0:16         ` Drew Adams
2018-10-17  1:25           ` Garreau, Alexandre
2018-10-17  1:58             ` Drew Adams
2018-10-17  9:00               ` Garreau, Alexandre
     [not found]               ` <mailman.2299.1539766826.1284.help-gnu-emacs@gnu.org>
2018-10-17  9:49                 ` Emanuel Berg
2018-10-17 15:42             ` Michael Heerdegen

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=ad2508c1-69ae-40eb-a039-48a3fb2503af@default \
    --to=drew.adams@oracle.com \
    --cc=galex-713@galex-713.eu \
    --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).