Sam Steingold <sds@gnu.org> wrote:
+---------------
| Is this the right idiom:
| (defmacro with-foo ((&key foo) &body body)
| `(... ,foo ... ,@body))
|
| (defmacro with-foo-bar ((&rest opts &key bar &allow-other-keys) &body body)
| (remf opts :bar)
| `(with-foo (,@opts)
| ... ,bar ... ,@body))
+---------------
Side question for the group: What are the rules for a &REST arg
in macros? If they're the same as functions, then could you possibly
get in trouble with Sam's idiom due to REMF destructively modifying
the "opts" list? That is, does one really need to do this instead?
(defmacro with-foo-bar ((&rest opts &key bar &allow-other-keys) &body body)
(let ((mutable-opts (copy-list opts)))
(remf mutable-opts :bar)
`(with-foo (,@mutable-opts)
... ,bar ... ,@body)))
-Rob
-----
Rob Warnock, PP-ASEL-IA <rpw3@rpw3.org>
627 26th Avenue <URL:http://www.rpw3.org/>
San Mateo, CA 94403 (650)572-2607