emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New jrpc.el JSONRPC library


From: Aaron Ecay
Subject: Re: New jrpc.el JSONRPC library
Date: Mon, 21 May 2018 15:37:04 +0100
User-agent: Notmuch/0.26 (https://notmuchmail.org) Emacs/27.0.50 (x86_64-pc-linux-gnu)

Hi João,

2018ko maiatzak 21an, João Távora-ek idatzi zuen:
> 
> Hi Aaron,
> 
> Nice, i didn't know about that. Does it have an equivalent to
> &allow-other-keys and &rest?

&allow-other-keys is always true for the pcase version.  As I understand
what &rest does, it lets you bind certain keys, and then bind the map
minus those keys to another variable.  Thereʼs nothing like that out of
the box, but it can easily be implemented:

(pcase-defmacro map-and-rest (rest-var &rest keys)
  `(and (map ,@keys)
        (app (map-filter (lambda (key _val) (not (memq key ',keys)))) 
,rest-var)))

(pcase-let* (((map-and-rest rest foo bar) '((foo . 1) (bar . 2) (baz . 3))))
  (list foo bar rest))
;; -> (1 2 ((baz . 3)))


-- 
Aaron Ecay



reply via email to

[Prev in Thread] Current Thread [Next in Thread]