Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

destructuring-bind for subset of plist

1 view
Skip to first unread message

Sam Halliday

unread,
May 25, 2016, 5:23:14 PM5/25/16
to
Hi all,

This causes an error

(cl-destructuring-bind
(&key a b)
'(:a "foo" :b 13 :c "bar")
(list a b))

because the :c key/value is not handled in the pattern match.

Often I find myself wanting to extract some subset of keys/values from a plist, but cl-destructuring-bind isn't appropriate because of this limitation.

Is there a way to make cl-destructuring-bind simply ignore unmatched keys in the EXPR? I'm not sure what the official common lisp behaviour is supposed to be here, is the error in the spec?

Note that the dash library has some support for a similar destructuring with -let, but that requires some boilerplate to assign a symbol to each key.

Best regards,
Sam

Barry Margolin

unread,
May 25, 2016, 9:30:59 PM5/25/16
to
In article <06aeb16e-843c-4964...@googlegroups.com>,
In CL you'd use (&key a b &allow-other-keys)

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
0 new messages