* destructuring-bind for subset of plist
@ 2016-05-25 21:23 Sam Halliday
2016-05-26 1:30 ` Barry Margolin
0 siblings, 1 reply; 2+ messages in thread
From: Sam Halliday @ 2016-05-25 21:23 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: destructuring-bind for subset of plist
2016-05-25 21:23 destructuring-bind for subset of plist Sam Halliday
@ 2016-05-26 1:30 ` Barry Margolin
0 siblings, 0 replies; 2+ messages in thread
From: Barry Margolin @ 2016-05-26 1:30 UTC (permalink / raw)
To: help-gnu-emacs
In article <06aeb16e-843c-4964-bf31-09fe16e4488d@googlegroups.com>,
Sam Halliday <sam.halliday@gmail.com> wrote:
> 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
In CL you'd use (&key a b &allow-other-keys)
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-26 1:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-25 21:23 destructuring-bind for subset of plist Sam Halliday
2016-05-26 1:30 ` Barry Margolin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).