From: Drew Adams <drew.adams@oracle.com>
To: Xiyue Deng <manphiz@gmail.com>, Eli Zaretskii <eliz@gnu.org>
Cc: "67669@debbugs.gnu.org" <67669@debbugs.gnu.org>
Subject: bug#67669: 29.1; Drop text suggesting using `and' to replace `if'
Date: Thu, 7 Dec 2023 19:37:30 +0000 [thread overview]
Message-ID: <SJ0PR10MB5488C49118C35F756EDA2139F38BA@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87fs0ducme.fsf@debian-hx90.lan>
> I quite like this suggestion[1] that `if' and `when' are used to guard side
> effects,
More clearly, `when' and `unless' (not `if', which is general - no special suggestion) are used to suggest (to humans) that they're used _only_ to perform side effects. With this convention, code shouldn't depend on their (always `nil') return value.
> whereas `and' and `or' are used for pure functions.
That too isn't really the convention (though it is what's said in that emacs.SE answer).
What should be said is that you use `and' and `or' when _the return value matters_, i.e., when it's used somewhere.
That does _not_ preclude the use of `and' and `or' to perform side effects. It's simply that the _return value matters_. Unlike `progn', the (Boolean) return value of each of their "steps" (sexps) determines whether subsequent ones are evaluated.
I've added another answer to the emacs.SE question you cited:
https://emacs.stackexchange.com/a/79744/105
But as you correctly noted, such conventions are a question of personal (or group) coding style. Lisp doesn't care or recognize any such meaning.
next prev parent reply other threads:[~2023-12-07 19:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 21:47 bug#67669: 29.1; Drop text suggesting using `and' to replace `if' Xiyue Deng
[not found] ` <handler.67669.B.170189926211616.ack@debbugs.gnu.org>
2023-12-06 22:08 ` Xiyue Deng
2023-12-07 6:28 ` Eli Zaretskii
2023-12-07 9:08 ` Xiyue Deng
2023-12-07 10:16 ` Eli Zaretskii
2023-12-07 17:49 ` Xiyue Deng
2023-12-07 17:56 ` Eli Zaretskii
2023-12-07 19:54 ` Xiyue Deng
2023-12-07 20:22 ` Eli Zaretskii
2023-12-07 20:37 ` Xiyue Deng
2023-12-07 21:29 ` Drew Adams
2023-12-08 9:11 ` Xiyue Deng
2023-12-08 6:25 ` Eli Zaretskii
2023-12-08 9:07 ` Xiyue Deng
2023-12-08 15:37 ` Drew Adams
2023-12-07 19:37 ` Drew Adams [this message]
2023-12-07 20:00 ` Xiyue Deng
2023-12-08 10:45 ` Sean Whitton
2023-12-08 22:41 ` Xiyue Deng
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=SJ0PR10MB5488C49118C35F756EDA2139F38BA@SJ0PR10MB5488.namprd10.prod.outlook.com \
--to=drew.adams@oracle.com \
--cc=67669@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=manphiz@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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).