all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Philip Kaludercic <philipk@posteo.net>, "Alfred M. Szmidt" <ams@gnu.org>
Cc: "arthur.miller@live.com" <arthur.miller@live.com>,
	"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: RE: [External] : Re: cond* vs pcase
Date: Tue, 6 Feb 2024 23:17:54 +0000	[thread overview]
Message-ID: <SJ0PR10MB54886A5AB7FFDF52F261565CF3462@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87v871qt5w.fsf@posteo.net>

> [`equal'] is not really slower than using `eq'...

With this I agree completely.  `equal' just calls
`eq' first thing, whenever it can (and I imagine
compiling even takes that out of the equation
often).

That said, _in such cases_ telegraphing the fact
that the Lisp objects can and should be compared
with `eq' _helps human readers_.

With a slight stretch of language, this can fall
under the heading of helping readers by expressing
"intent".

> The pattern matching code is all generated at compile-time, and even
> uses the `eq' to compare symbols, instead of the less specific `eql'
> (!).

Yes.  It's not about performance.

> Yes, this might be a fundamental disagreement, but I
> still don't think that using more abstract means to
> solve a problem is inherently wrong.

It's not "inherently wrong", if you're measuring
"wrong" by performance - or perhaps even by some
other criteria.

> It might be a personal preference, but nothing
> we could derive a general rule from -- which is fine.

It is indeed a style question.  But it doesn't
follow that stylistic guidelines don't, or can't,
or shouldn't exist.

The existing, documented Elisp guidelines don't
cover this.  Nor do they cover other conventions
such as using `when'/`unless' to telegraph that
the returned value isn't important as such.

They could, but they don't.  Such conventions
for conditionals do exist, and they're even
mentioned in CLTL2, IIRC (though CLTL2 doesn't
impose any style guidelines).

So yes, it's a personal stylistic preference.
Nevertheless, it doesn't hurt to discuss the
reasons for such a style - or for other styles.

Have we seen (here, now) any _reasons_ in favor
of always using `pcase' when something else
might do the job more simply?  Have we seen an
argument an argument in _favor_ of "using more
abstract"?

I can think of a couple, but they don't convince
me in light of the "communicate intent" argument:

1. One can maybe save some time or effort by
   learning only one construct (`pcase').  One
   size fits all has a certain economy to it.

2. With `pcase', later updates might sometimes
   not require as much editing.

I've never been an adoptee of the second.  I
prefer to have the code always express better
the intent, even if that means I need to edit
it more later, when things change slightly.
This can easily be the case with conventions
about when to use `if', `and', `when', etc.,
for example.

A lot is in the eye of the beholder - the
expected readers of the code.  Higher-order
functions such as `reduce' are elegant, and
their use can be succinct, for example.
(Elisp isn't a great fit for them, however.)
But a reader needs to have been introduced
to the genre.

YMMV.  Different strokes for different folks.
More and less abstraction can each have their
advantages, even for human readers (not to
mention performance).  



  reply	other threads:[~2024-02-06 23:17 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05 14:30 cond* vs pcase Arthur Miller
2024-02-05 15:13 ` Eli Zaretskii
2024-02-05 16:06 ` Alfred M. Szmidt
2024-02-05 18:39   ` Philip Kaludercic
2024-02-06 12:30     ` Arthur Miller
2024-02-06 16:17     ` Alfred M. Szmidt
2024-02-06 16:35       ` [External] : " Drew Adams
2024-02-06 16:50       ` Philip Kaludercic
2024-02-06 17:27         ` Alfred M. Szmidt
2024-02-06 18:57           ` Philip Kaludercic
2024-02-06 19:04             ` Alfred M. Szmidt
2024-02-06 19:39               ` Philip Kaludercic
2024-02-06 23:17                 ` Drew Adams [this message]
2024-02-06 19:12             ` [External] : " Drew Adams
2024-02-06 20:08               ` Adam Porter
2024-02-06 23:32                 ` Drew Adams
2024-02-07 13:14                   ` Arthur Miller
2024-02-07 13:43                     ` Po Lu
2024-02-07 17:09                       ` Drew Adams
2024-02-07 17:44                       ` Tomas Hlavaty
2024-02-09  3:52                         ` Richard Stallman
2024-02-07 18:00                       ` Arthur Miller
2024-02-07 18:22                         ` Alfred M. Szmidt
2024-02-08  1:55                           ` Po Lu
2024-02-08  2:49                             ` Philip Kaludercic
2024-02-08  3:36                               ` Po Lu
2024-02-08  7:04                             ` Eli Zaretskii
2024-02-08 17:01                               ` Alfred M. Szmidt
2024-02-08 17:01                             ` Alfred M. Szmidt
2024-02-09  1:30                               ` Po Lu
2024-02-08  5:01                         ` Po Lu
     [not found]                           ` <DU2PR02MB10109B7AC39F995BFE266EF5396442@DU2PR02MB10109.eurprd02.prod.outlook.com>
2024-02-08  7:36                             ` Sv: " Arthur Miller
2024-02-12 21:39                       ` Stefan Monnier via Emacs development discussions.
2024-02-07 17:14                     ` Drew Adams
2024-02-07  5:32             ` Yuri Khan
2024-02-07 12:43               ` Arthur Miller
2024-02-07 17:41                 ` Alfred M. Szmidt
2024-02-07 18:36                   ` Arthur Miller
2024-02-07 19:12                     ` Alfred M. Szmidt
2024-02-07 21:20                       ` Arthur Miller
2024-02-06 17:29         ` [External] : " Drew Adams
2024-02-06 17:41           ` Alfred M. Szmidt
2024-02-06 17:50         ` Thierry Volpiatto
2024-02-06 19:04           ` Alfred M. Szmidt
2024-02-07 15:03           ` Barry Fishman
2024-02-07 17:22             ` [External] : " Drew Adams

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

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

  git send-email \
    --in-reply-to=SJ0PR10MB54886A5AB7FFDF52F261565CF3462@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=ams@gnu.org \
    --cc=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    --cc=philipk@posteo.net \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.