[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: destructuring-bind for subset of plist
From: |
Barry Margolin |
Subject: |
Re: destructuring-bind for subset of plist |
Date: |
Wed, 25 May 2016 21:30:56 -0400 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
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 ***