bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#67611: [PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-des


From: João Távora
Subject: bug#67611: [PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-destructuring-bind`
Date: Thu, 11 Jan 2024 22:46:01 +0000

On Thu, Jan 11, 2024 at 10:13 PM Stefan Kangas <stefankangas@gmail.com> wrote:
>
> João Távora <joaotavora@gmail.com> writes:
>
> > On Thu, Jan 11, 2024 at 9:12 PM Stefan Kangas <stefankangas@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





reply via email to

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