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: Richard Stallman <rms <at> gnu.org>
To: João Távora <joaotavora <at> gmail.com>
Cc: 67611 <at> debbugs.gnu.org
Subject: bug#67611: [PATCH] Add a Pcase pattern `cl-lambda` equivalent to `cl-destructuring-bind`
Date: Tue, 16 Jan 2024 22:29:57 -0500
[[[ 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. ]]]

  > > Would someone please tell me what syntax is being proposed here,
  > > and show me an example, saying what it would mean?

  > Common-lisp style lambda lists.  The ones containing the &key and
  > &optional with more features.

Thanks for answering, but its meaning is not concretely clear to me.

Could you tell me more concretely what this proposed feature would
look like in use?  Perhaps with an example including context?

pcase does not use lambda lists, and neither does cond*.  They are
based on the backquote construct, which does not use &-keywords.
I see a danger of conceptual incoherence here.

If we want to extend the kinds of constructs for destructuring lists,
we should extend the features of backquote.  That would give a more
coherent interface.

We could define ,? to specify an element that might br missing,
and ,& to specify a keyword argument.  These could work in backquote
for constructing lists as well as in destructiring.

(let ((x 9) (y 10) (z nil) (u 11) (v nil) (w '(12 13)))
  `(a ,x ,?y ,?z ,&(foo u) ,&(bar v) . ,w))

=> (a 9 10 foo 11 12 13)

That is my first stab at the design.  I think it is better,
for this purpose, than using parmlist keywords.
But maybe with more thinking we can find improvements.

-- 
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)






This bug report was last modified 118 days ago.

Previous Next


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