[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pcase defuns
From: |
Andrew Hyatt |
Subject: |
Re: pcase defuns |
Date: |
Wed, 22 Dec 2021 20:52:02 -0500 |
On Tue, Dec 21, 2021 at 11:18 PM Richard Stallman <rms@gnu.org>
wrote:
[[[ To any NSA and FBI agents reading my email: please consider
]]] [[[ whether defending the US Constitution against all
enemies, ]]] [[[ foreign or domestic, requires you to follow
Snowden's example. ]]]
> I agree that just implementing everything in a function is
> reasonable. For that, just using pcase seems good enough,
> although it might be interesting to have a very different
> way of writing a function such as
> (pcase-defun mytest
> "Demonstrates a way of writing defuns via pcase matching."
> ((a b _) "a b match") (`(c ,v _) (format "c %s match" v)))
This avoids the split-up-definition problems I was talking
about, since it is all in one place with one name.
Please make the defining form's name follow th convention of
starting with `def', so people and tools will recognize that it
is a defining form.
Also, why use `pcase' in the name? According to the docs of
`pcase', this pattern matching is not similar.
This really is the same as pcase, with some transformation to make
the backquote-style and other style equivalent. For example, the
above would translate to:
(pcase val
((seq 'a 'b _) "a b match")
(`(c ,v ,_) (format "c %s match" v)))
I think we could probably just use pcase style, but I wanted to
make the style more consistent between backquote and normal pcase
matching. For example, backquote matching can match a sequence of
matches, but normal matching would require the "seq" matcher at
the start to do the same thing.
It could be that the way I transform these can be improved, in
fact, maybe the following would be better:
(def-pcase mytest
"Demonstrates a way of writing defuns via pcase matching."
(('a 'b '_) "a b match") (('c v '_) (format "c %s match" v)))
Or, as you say, perhaps if we use the name pcase we should just be
completely consistent with how pcase does things, and not to make
it more internally self-consistent.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
- Re: pcase defuns, (continued)
Re: pcase defuns, LdBeth, 2021/12/22
Re: pcase defuns, Stefan Monnier, 2021/12/19
Re: pcase defuns, Stefan Monnier, 2021/12/21
Re: pcase defuns, Richard Stallman, 2021/12/19
Re: pcase defuns, Po Lu, 2021/12/22