unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Sam Halliday <sam.halliday@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: destructuring-bind for subset of plist
Date: Wed, 25 May 2016 14:23:12 -0700 (PDT)	[thread overview]
Message-ID: <06aeb16e-843c-4964-bf31-09fe16e4488d@googlegroups.com> (raw)

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


             reply	other threads:[~2016-05-25 21:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25 21:23 Sam Halliday [this message]
2016-05-26  1:30 ` destructuring-bind for subset of plist Barry Margolin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=06aeb16e-843c-4964-bf31-09fe16e4488d@googlegroups.com \
    --to=sam.halliday@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).