emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : Re: cond*


From: Drew Adams
Subject: RE: [External] : Re: cond*
Date: Sat, 6 Jan 2024 22:25:06 +0000

Perhaps off-topic, but I think the difficulty
of human-parsing pcase sexps can be reduced
considerably if each variable bound by the
sexp is clearly shown to be just that.

Even just following a trivial convention,
such as prefixing each variable name with,
`?', would help.

(I'd even suggest that this could be part of
the required syntax - except that pcase is
no longer new and there are lots of pcase
occurrences already out there in the wild.)

Here's an example from bug #68029 (closed as
"done" but really was "wont-fix" -- nothing
was done).  The vars introduced here are
?msg and ?code:

(pcase (get-return-code x)
  ((and (pred stringp) ?msg)
   (message "%s" ?msg))
  ('success       (message "Done!"))
  ('would-block   (message "Sorry, can't do it now"))
  ('read-only     (message "The shmliblick is read-only"))
  ('access-denied (message "You do not have the needed rights"))
  (?code          (message "Unknown return code %S" ?code)))

[ I changed `msg' and `code' in the Elisp
  manual example to `?msg' and `?code', to
  point out that it introduces two variables,
  whereas it was claimed that it introduced
  _NO_ vars and that _therefore_ the pcase
  version was clearer than using `let'.  I
  even used uppercase, `?MSG' and ?CODE, to
  make the presence of the vars clearer.
  
  The doc _still incorrectly claims_ that
  the pcase version is superior because it
  doesn't need to introduce any vars such
  as `code'.  The author and an Emacs
  maintainer, at least, apparently missed
  that pcase binds these variables.  IOW,
  the fact of the var bindings isn't as
  clear as it could be. ]

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=68029#13

reply via email to

[Prev in Thread] Current Thread [Next in Thread]