unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Jean Louis <bugs@gnu.support>,
	"help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : Re: operations on path lists
Date: Wed, 8 Feb 2023 02:48:12 +0000	[thread overview]
Message-ID: <SJ0PR10MB54887B26070F397584371C06F3D89@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <Y+LTPZBJvUOAbiP8@protected.localdomain>

> Let us look at `when' little:
> 
> - you place `when' when you need `nil' as last resort

I don't.  I do just the opposite.  I use `when'
and `unless' only when the code doesn't use/depend
on the return value.  (I'm guessing that's what
you meant by needing nil as a last resort, though
they always return nil.)

Before Elisp borrowed `when' and `unless' from
other Lisps (e.g. Common Lisp), the idiom,
especially for a single condition, was to use `or'
in (or condition do-something) instead of `unless',
and likewise for `and' and `when'.  That that,
usually at top level in a function body.  I still
have some of those `or' sexps, as does standard
Emacs code.

> - what if you change your mind in future and wish to modify function
>   to return "" as last resort?

I don't use `when' for its return value (which,
again, is always nil).  I might use `if' or `and'
(or `case' or `cond'...).

>   you have to restructure it.

Yes, I mentioned this in my reply to EB yesterday.
That's the advantage of doing what you prefer to
do, e.g., use `cond'.  At the cost of losing any
indication of the meaning/intention of any given
`cond' clause and the return value.

`cond' is a very versatile control structure that,
consequently, gives you little means to express
intention, other than with comments.  One `cond'
clause looks like any other - could do or mean,
and return, anything at all.

> - without parenthesis highlighting sometimes it becomes very difficult
>   to understand what did `if' author intended to say?

I don't grok that.  But then, I don't use `if'
unless there are both a then and an else part.
I take the time to rewrite, yes, as needed,
to communicate to myself (as reader) just what
the code means to do.

> - multiple `if' statements one ofter other do not look nice and
>   readable,

That's not very common IMO.  Maybe a couple
levels sometimes.

> Some people write long functions, if, then, when, it is not nicely
> indented, restructuring is difficult, what did author want to say?
> Hard to think of it.

Probably depends on what you're used to.  But
if each of `if', `when', `unless', `and', and
`or' is used in a way that says what's intended
then it's pretty easy to understand.  There's
no guessing about whether the return value of
a given `if' is used etc.  (For me, it always
is, or I wouldn't use `if'.)

  reply	other threads:[~2023-02-08  2:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-04  5:32 operations on path lists Samuel Wales
2023-02-04  6:32 ` Jean Louis
2023-02-04  8:06   ` Emanuel Berg
2023-02-04 17:21     ` [External] : " Drew Adams
2023-02-04 18:32       ` Jean Louis
2023-02-04 21:51         ` Emanuel Berg
2023-02-07  8:34           ` Jean Louis
2023-02-07 10:26             ` Emanuel Berg
2023-02-07 22:39           ` Jean Louis
2023-02-08  2:48             ` Drew Adams [this message]
2023-02-08 18:46               ` Drew Adams
2023-02-08 20:09               ` Jean Louis
2023-02-04 18:28     ` Jean Louis
2023-02-04 21:41       ` Emanuel Berg
2023-02-07  8:33         ` Jean Louis
2023-02-07 10:30           ` Emanuel Berg
2023-02-07 14:55             ` [External] : " Drew Adams
2023-02-07 14:55           ` Drew Adams
2023-02-04 21:44       ` Samuel Wales
2023-02-04 21:49         ` Samuel Wales
2023-02-04 14:59   ` Emanuel Berg
2023-02-07  7:35     ` Jean Louis
2023-02-07 10:27       ` Emanuel Berg
2023-02-11  8:18 ` James Thomas
2023-02-11 14:02 ` Ruijie Yu via Users list for the GNU Emacs text editor

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=SJ0PR10MB54887B26070F397584371C06F3D89@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=bugs@gnu.support \
    --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).