GNU bug report logs -
#67611
[PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-destructuring-bind`
Previous Next
Reported by: Okamsn <okamsn <at> protonmail.com>
Date: Sun, 3 Dec 2023 20:35:01 UTC
Severity: wishlist
Tags: patch
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On Thu, Jan 11, 2024 at 10:13 PM Stefan Kangas <stefankangas <at> gmail.com> wrote:
>
> João Távora <joaotavora <at> gmail.com> writes:
>
> > On Thu, Jan 11, 2024 at 9:12 PM Stefan Kangas <stefankangas <at> gmail.com> wrote:
> >
> >> Thanks for the patch. I can only echo the sentiment already given here,
> >> that making `pcase' more complex won't do much for its popularity.
> >
> > This sentiment is not unanimous. If pcase is naturally extensible,
> > using that ability is not making it more complex. That'd be akin
> > to saying "defun" is made more complex because too many functions
> > are popping up.
> >
> > Just wanted register this position. Though I don't know for sure if
> > the patch is simply adding a new extension to pcase or changing
> > its core structure.
> >
> > I wish Okamsn would show one or two simple examples usage
> > of something you can't do with pcase today, but you would be
> > able to with the patch.
In the meantime, I've had a look at the patch file to learn
about this pcase extension.
1. It is a pure extension. The extension code happens in cl-macs.el
2. It is an alternative to cl-destructuring-bind, also defined
in that file, with more typing involved.
3. It _seems_ it has the advantage that it relies on very little
of cl-macs.el, like maybe just cl-copy-list. Ie it could easily
be changed to live in another file. It could even be a (better?)
base to write cl-destructuring-bind and other cl-macs things on top
of. And to write other utils like Alexandria's
cl-parse-ordinary-lambda-list or destructuring-case [1].
A good lambda-list destructuring tool is valuable by itself, even
without pcase integration.
4. Pcase integration is a "nice to have". In the provided tests, the
new extension is only tested as a destructuring aid, so I cannot tell
very well how it fares int the matching aspect of pcase. For example
I did this experiment:
(pcase (list 42 41 :c 42)
((cl-arglist (42 42 &key c))
(list c))
((cl-arglist (42 b &rest more))
(list b more)))
This matches the second case, which is good and returns (41 (:c 42))
But how do I construct a case that matches only if the provided
value to c is 42, if this is at all possible?
> feel free to reopen the bug report if you think it makes sense.
I think it makes sense, but I don't know how to do that. Just write
reopen 67611/thanks to this tracker?
João
[1]: https://gitlab.common-lisp.net/alexandria/alexandria
This bug report was last modified 146 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.