GNU bug report logs - #67611
[PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-destructuring-bind`

Previous Next

Package: emacs;

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

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#67611: closed ([PATCH] Add a Pcase pattern `cl-lambda`
 equivalent to `cl-destructuring-bind`)
Date: Sun, 23 Feb 2025 06:09:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sun, 23 Feb 2025 06:07:33 +0000
with message-id <CADwFkmnTN4NLJ8ocChjSW3PSwOx6mAETmfCV7r=Np0OKTqCqow <at> mail.gmail.com>
and subject line Re: bug#67611: [PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-destructuring-bind`
has caused the debbugs.gnu.org bug report #67611,
regarding [PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-destructuring-bind`
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
67611: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67611
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Okamsn <okamsn <at> protonmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: [PATCH] Add a Pcase pattern `cl-lambda` equivalent to
 `cl-destructuring-bind`
Date: Sun, 03 Dec 2023 20:33:35 +0000
[Message part 3 (text/plain, inline)]
Hello,

The attached patch adds the pattern `cl-lambda` for Pcase, which works 
like `cl-destructuring-bind`. There are two differences with the lambda 
lists:

1. It does not support `&environment`
2. Without `&allow-other-keys` or `:allow-other-keys t`, the pattern 
will fail to match if their are unmatched keys in EXPVAL, but it does 
not throw an error.

The variable that would be bound in the lambda list can be Pcase 
patterns themselves, with two exceptions:

1. Using a sub-pattern as the cdr of a dotted list, like "(cl-lambda (a 
. `(,b . ,c))" doesn't work, since the pattern won't always look like a 
dotted list.
2. For constructs that use a sub-list to provide additional values, such 
as `&optional`, `&key`, and `&aux`, the sub-pattern only works inside 
the sub-list.  For example, one could do "(cl-lambda (&optional (`(,a 
,b))" but not "(cl-lambda (&optional `(,a ,b)))".

The pattern is useful when one wants to combine the features of `pcase` 
and `cl-destructuring-bind`, such combining the optional values with the 
`pred` or `guard` patterns.

Thank you.
[0001-Add-the-Pcase-pattern-cl-lambda-for-matching-lambda-.patch (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
From: Stefan Kangas <stefankangas <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Okamsn <okamsn <at> protonmail.com>, 67611-done <at> debbugs.gnu.org,
 João Távora <joaotavora <at> gmail.com>
Subject: Re: bug#67611: [PATCH] Add a Pcase pattern `cl-lambda` equivalent to
 `cl-destructuring-bind`
Date: Sun, 23 Feb 2025 06:07:33 +0000
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>>> 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.
>
> Agreed.
>
>> 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.
>
> It's a pure extension.  The question is not whether the patch is good or
> bad or whether it makes the existing infrastructure too complex.
> It's rather where should such a thing live.
>
> I don't think there's a clear enough need for it right now in Emacs core
> to motivate its integration in Emacs proper.  Also, because several
> people have expressed an opinion that leans towards recommending that
> Emacs's own code should probably better avoid using this functionality.
>
> I'd be quite happy to include such a think in GNU ELPA, OTOH.

This thread lead to some interesting discussions, but ultimately I think
for the OPs suggestion to fly it would have to be repackaged as a GNU
ELPA package.  So this is the recommendation for now, and please open a
new bug report for the GNU ELPA submission.

With that, I'm closing this bug report.


This bug report was last modified 147 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.