all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* cond* vs pcase
@ 2024-02-05 14:30 Arthur Miller
  2024-02-05 15:13 ` Eli Zaretskii
  2024-02-05 16:06 ` Alfred M. Szmidt
  0 siblings, 2 replies; 46+ messages in thread
From: Arthur Miller @ 2024-02-05 14:30 UTC (permalink / raw)
  To: emacs-devel

After skimming through the toms of the emacs-devel, here is what I got:

RMS does not like pcase; it is hard to understand and under-documented, which is
actually true, at least for the latter. To remedy, you are re-invent the idea
with a different syntax.

I have been hanging on /r/Emacs for a few years now, and here is my prediction
of a future hypothetical Emacs Lisp learner asking on /r/Emacs:

"Which should I use? Pcase or cond*? Which one do you recommend?"

And hypotetical future answers:

*Toms of similar discussions similar to the one on this mailing list going on
for days, but in Reddit comments, suggestions in different directions, and more
confusion.*

To start with, I think none on this mailing list has asked this question
yet (or have I missed it?): why does it have to be a single form that does all
of the pattern stuff?

I use pcase often; but I use it just as a better cond. For example I find this
handy:

(defvar foo nil) <-- foo is some symbol

(pcase foo
  ('bar (do-some-bar-stuff))
  ('baz (do-some-baz-fluff)))

or this:

(setq foo "some-string")

(pcase foo
  ("foo" (do-foo-case))
  ("bar" (do-bar-case)))

I don't use much of pred stuff and other advancements. I probably never will;
there are other ways to structure the code. Not everything has to be done by one
and the same form, but if someone else does, power to them, I have nothing
against it.

For the same reason I also use cl-loop very sparingly (I almost never feel need
to reach for it in my own code). I think "while", "dotimes" and "dolist" tells
me much better the intention of my loop and what I wanted to do, than looking at
cl-loop and deciphering if it is a while-loop, an iteration through a collection
or a repeat loop. For the same reason, in Common Lisp, I don't try to write the
entire programs with Common Lisp format directives, nor do I try to write entire
programs with a single regular expression as some people seems to prefer. That
makes code ugly and difficult to read; I prefer to structure the code with
simpler Lisp statements.

Why this obsession that we have to have one form, be it pcase or cond*, that
covers all cases of pattern usage in conditions?

My second objection is, as many other stated here; if pcase is that hard,
resource heavy, and underdocumented, have you considred working to fix problems
and on the documentation of pcase, perhaps with Stefan?

Is it possible to simplify pcase in some places? You could have maybe worked on
pcase to make it easier to use?

Could pcase be refactored so that parts of it are loaded into the core and used
in Emacs core, and some constructs are made available only after user requires
an extra library?

If it is too resource demanding and macro expansions are a problem, is it
possible to perhaps pre-load parts of pcase implemented in only primitives
exported from the C runtime?

Instead of working together with Stefan to make pcase and Emacs Lisp a better
and easier language to use and learn, cond* is pushing out the worst of all
ideas: implementing yet-another pattern language and adding even more cognitive
load to an already arcane implementation of a Lisp language. Now Alan will have
to learn *two* pattern languages to debug Emacs instead of one, because pcase is
not going away. It will stay with us as long a Emacs lives, just like all other
Elisp constructs, unless you want to invalidate or rewrite all third-party code
out there, which is thousands of packages by now.

I am not a best writer and diplomat, but this link summarizes what I percieve
what pcase is trying to do, and cond* is just adding more of the same to it:

https://xkcd.com/927/

I understand the objections to pcase, but I don't understand the answer.

Best regards
/arthur



^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2024-02-12 21:39 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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                 ` [External] : " Drew Adams
2024-02-06 19:12             ` 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

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.