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>, help-gnu-emacs@gnu.org
Subject: RE: `when' vs. `and' / `unless' vs `or'
Date: Tue, 16 Oct 2018 15:13:16 -0700 (PDT)	[thread overview]
Message-ID: <99393ed6-6947-4246-ad8e-b4984c776a53@default> (raw)
In-Reply-To: <87o9btob5k.fsf@portable.galex-713.eu>

Do whatever you like. ;-) Different people use different styles.
There is no standard or even a convention. Common Lisp
suggests some conventions, but there too there is nothing
official.

I use `when' and `unless' when I want to show a human
reader (mainly me) that the code doesn't use or care about
the return value. I don't use them when the returned `nil'
could be important.

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).

I use `cond' when I have two or more sexps for each of
the true and false parts or I have more than two conditions.

I use `case' when the conditions would just test the
same symbol for equality against different values.

I don't use `pcase' much. Nothing against it, really.

Yes, the way I use `if' etc. can mean that I change which
form I use as the code evolves. I'd rather spend more
time fiddling with the code, in order to have the result
be easier to understand (for a human).

YMMV.



  reply	other threads:[~2018-10-16 22:13 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 [this message]
2018-10-16 22:38   ` Garreau, Alexandre
2018-10-16 23:21     ` Drew Adams
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=99393ed6-6947-4246-ad8e-b4984c776a53@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).