all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'" <help-gnu-emacs@gnu.org>
Subject: RE: [External] : Re: Emacs 30.0 warning from `cl-pushnew' and `memql'
Date: Sat, 31 Dec 2022 02:45:20 +0000	[thread overview]
Message-ID: <SJ0PR10MB54883D8FB8C0EB3103BE7D15F3F19@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <jwvzgb4phqk.fsf-monnier+emacs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3958 bytes --]

> AFAICT [`case's] "simplicity" is just the fact
> that it's a lot more restrictive, so you can
> get the same simplicity by resisting the
> urge to use the extra features of `pcase`,
> without having to learn another syntax.

That's what you've been claiming, and what I've
been requesting examples of.  Please show, for
the "restrictive" use case that `case' fulfills,
corresponding examples of `case' and `pcase'
that demonstrate, in your eyes, that `pcase' is
simpler (or even as simple).

Examples head-to-head for that simple case will
show the differences.  So far, you've given only
non-examples of non-`case' syntax, to show the
misunderstanding you've encountered.  I've shown
some `case' examples.  Please show equivalent,
but in-your-eyes simpler, `pcase' ones.  Or show
other examples for the same simple use-case.

It's not about comparing/contrasting `case' and
`pcase' in general.  It's about the particular
use case that `case' was designed to address.
How does `pcase' excel there by being simpler?

I haven't argued that `pcase' should go away.
I argue that `case' is better for what it does:
that simple, common, "restrictive" use case.
Please show us otherwise.

But more generally, and perhaps less as a matter
of preference or personal taste, I argue that
it's good to offer _both_ `pcase' and `case' as
part of Emacs, i.e., to treat `case' the way we
treat `cond', `if', `when', ... and `pcase'.

I'm not surprised that some Emacs users have
incorrectly thought that the keylists and keys
get evaluated, and so have mistakenly quoted
them - because, as I just discovered and pointed
out, the Emacs _doc doesn't say_ that they're
not evaluated.

How is a user to know whether something gets
evaluated or not by a macro, if the doc doesn't
speak to that?  Do we expect a user discovering
a control structure to immediately macroexpand
guess uses to see what the expansions give?  Or
to analyze the macro's definition?

It's perfectly understandable that someone
might just assume evaluation everywhere,
especially since the doc here keeps repeating
"evaluates".  The only parts for which it
doesn't say anything about evaluation are the
parts it really needs to say something about:
keys aren't evaluated.

On the other hand, the Common Lisp doc points
out clearly (and even emphasizes) that keys
aren't evaluated.

That doc difference alone could explain why
you've see some Elisp users confused and
mistaken, and why I've never seen that among
CL users (and you apparently haven't either).
Maybe the problem you've noticed was just
caused by our poor `cl-case' doc.

How about we fix the doc and also raise `case'
to first-class citizenship along with its
compatriots?
___

You haven't responded to specific points I've
made - that's your right.  But could you at
least please speak to this, which to me seems
to be a bug in the `pcase' node in the Elisp
manual, where it compares `pcase' and `cl-case':

 It shows a `pcase' example which starts with
 this: (pcase (get-return-code x) ...
 
  "With 'cl-case', you would need to explicitly
   declare a local variable 'code' to hold the
   return value of 'get-return-code'."

 Huh? Does that mean you need to use a variable
 as the first arg to `cl-case'?  If so, that's
 not right.
 
 (defun get-return-code (arg)
   (if (< arg 42) 'success 'failure))
 
 (let ((x  13))
   (cl-case (get-return-code x)
     (success (message "Done!"))
     (t       (message "Unknown!"))))
 
  ==> Done!
 
 And with x bound to 56, ==> Unknown!
 
 We didn't "declare a local variable ... to
 hold the return value of `get-return-code'."
 ...
 It's the value returned from evaluating the
 sexp (get-return-code x) that `cl-case' tries
 to match (using `eql') against symbol `success'.
 `cl-case' doesn't need its first arg to be a
 "local variable".
 
 Let me know what I'm missing here.

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 17074 bytes --]

  reply	other threads:[~2022-12-31  2:45 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-26 20:38 Emacs 30.0 warning from `cl-pushnew' and `memql' Emanuel Berg
2022-12-27  6:56 ` Jean Louis
2022-12-27 10:28 ` Michael Heerdegen
2022-12-27 11:33   ` Emanuel Berg
2022-12-27 11:39   ` Emanuel Berg
2022-12-28  3:23     ` [External] : " Drew Adams
2022-12-28  4:23       ` Emanuel Berg
2022-12-29 22:27         ` Drew Adams
2022-12-30 22:27           ` Emanuel Berg
2022-12-30  6:30         ` tomas
2022-12-28  6:25     ` tomas
2022-12-28 11:59       ` Michael Heerdegen
2022-12-28 12:41         ` tomas
2022-12-28 12:45           ` Emanuel Berg
2022-12-28 13:19           ` Emanuel Berg
2022-12-28 14:54           ` Emanuel Berg
2022-12-29 22:31             ` Stefan Monnier via Users list for the GNU Emacs text editor
2023-01-08  4:18               ` Emanuel Berg
2023-01-08 18:54                 ` Andreas Eder
2022-12-28 17:57           ` [External] : " Drew Adams
2022-12-28 18:10             ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-28 19:29               ` Emanuel Berg
2022-12-28 19:35               ` Drew Adams
2022-12-28 19:36               ` tomas
2022-12-28 19:24             ` Emanuel Berg
2022-12-28 17:54         ` Drew Adams
2022-12-28 18:05           ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-28 19:35             ` Drew Adams
2022-12-29  3:34               ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-29 19:06                 ` Drew Adams
2022-12-29 19:45                   ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-29 22:00                     ` Drew Adams
2022-12-29 22:25                       ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-30  7:29                         ` Drew Adams
2022-12-30 18:55                           ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-30 22:55                             ` Drew Adams
2022-12-31  0:08                               ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-31  2:45                                 ` Drew Adams [this message]
2022-12-31  4:53                                   ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-28 19:21           ` Emanuel Berg
2022-12-28 20:24         ` Jean Louis
2022-12-28 20:56           ` Emanuel Berg
2022-12-28 21:24           ` [External] : " Drew Adams
2022-12-28 22:47             ` Jean Louis
2022-12-28 23:48               ` Emanuel Berg
2022-12-29  6:03               ` tomas
2022-12-29  6:59                 ` Emanuel Berg
2022-12-29  7:08                 ` Emanuel Berg
2022-12-29  7:19                 ` Emanuel Berg
2022-12-29 22:41                   ` Drew Adams
2022-12-30 23:03                     ` Emanuel Berg
2022-12-30  6:35                   ` tomas
2022-12-29  9:18                 ` Jean Louis
2022-12-29 10:04                   ` Emanuel Berg
2022-12-29 10:12                   ` tomas
2022-12-29 10:20                     ` Emanuel Berg
2022-12-29 10:26                     ` Emanuel Berg
2022-12-29 10:36                   ` Michael Heerdegen
2022-12-29 14:47                 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-29 10:39           ` Michael Heerdegen
2022-12-28 12:44       ` Emanuel Berg

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=SJ0PR10MB54883D8FB8C0EB3103BE7D15F3F19@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.