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

From: Stefan Monnier <[email-masked]>
Date: Fri, 12 Jan 2024 10:38:50 -0500

>> 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.
> Those people are trying to come up with alternative pattern-matching
> libraries which we start to see are not simpler or as powerful
> as pcase.

Only some of them are.  Others are perfectly happy with using `pcase`
but still aren't super happy about combining the complexity of `pcase`
with that of CL destructuring syntax.

Personally I'm rather put off by the difficulty of figuring out which
part is using CL syntax and which part is using Pcase: the transition
from Pcase to CL is fairly clear (marked by `cl-arglist` or somesuch),
but the other is much less so.

I'd be happier with a `cl-arglist` which cannot contain nested Pcase
patterns (i.e. a one-way street from Pcase to CL) with
`cl-destructuring-bind` reimplemented on top of it.

I'd also be interested in a new Pcase pattern that provides the part of
`cl-arglist` functionality that's missing from current Pcase patterns
(like "optional" elements in a list), but with a syntax that blends
better in Pcase patterns.

> IOW there is no general purpose-util like Alexandria's
> 'parse-ordinary-lambda-list', and this could be it.  It could
> not only be used to simplify and add coherence to many of these
> existing compile-time structures, for example helping simplify
> things and address FIXMEs in cl-lib.el.

That's a different question: improving up cl-lib's implementation would
be welcome, yes.  That's not what the current patch does, tho.

        Stefan