From: Andrew Hyatt <ahyatt@gmail.com>
To: rms@gnu.org
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: pcase defuns
Date: Wed, 22 Dec 2021 20:52:02 -0500 [thread overview]
Message-ID: <m2o85884vx.fsf@andrews-mbp.lan> (raw)
In-Reply-To: <E1mzt5F-0005ia-23@fencepost.gnu.org>
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)
next prev parent reply other threads:[~2021-12-23 1:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-19 4:53 pcase defuns Andrew Hyatt
2021-12-19 8:34 ` Tassilo Horn
2021-12-19 15:33 ` Andrew Hyatt
2021-12-19 17:16 ` Tassilo Horn
2021-12-19 19:05 ` Stefan Monnier
2021-12-20 5:56 ` Tassilo Horn
2021-12-22 14:07 ` LdBeth
2021-12-19 17:23 ` Stefan Monnier
2021-12-19 21:08 ` Andrew Hyatt
2021-12-21 4:15 ` Richard Stallman
2021-12-21 5:20 ` Andrew Hyatt
2021-12-22 4:18 ` Richard Stallman
2021-12-23 1:52 ` Andrew Hyatt [this message]
2021-12-24 4:13 ` Richard Stallman
2021-12-21 15:32 ` Stefan Monnier
2021-12-20 4:43 ` Richard Stallman
2021-12-23 2:30 ` Po Lu
2022-03-26 17:41 ` Andrew Hyatt
2022-03-27 9:31 ` Stefan Monnier
2022-03-27 18:17 ` Andrew Hyatt
2022-03-28 4:15 ` Richard Stallman
2022-03-30 1:28 ` Andrew Hyatt
2022-03-31 4:27 ` Richard Stallman
2022-04-17 22:09 ` Andrew Hyatt
2022-04-19 3:48 ` Richard Stallman
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2o85884vx.fsf@andrews-mbp.lan \
--to=ahyatt@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=rms@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).