[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
- Re: cond*, Ihor Radchenko, 2024/01/01
- Re: cond*, Richard Stallman, 2024/01/02
- Re: cond*, Ihor Radchenko, 2024/01/03
- Re: cond*, Richard Stallman, 2024/01/04
- Re: cond*, Ihor Radchenko, 2024/01/06
- RE: [External] : Re: cond*,
Drew Adams <=
- Re: [External] : Re: cond*, Richard Stallman, 2024/01/07
- RE: [External] : Re: cond*, Drew Adams, 2024/01/08
- map seq and radix-tree-leaf, in pcase, Richard Stallman, 2024/01/08
- Re: cond*, Richard Stallman, 2024/01/07
- Re: cond*, Ihor Radchenko, 2024/01/10
- Re: cond*, Richard Stallman, 2024/01/12
- Re: cond*, Adam Porter, 2024/01/13
- Re: cond*, Richard Stallman, 2024/01/15
- Re: cond*, Ihor Radchenko, 2024/01/13
- Re: cond*, Richard Stallman, 2024/01/14