Open filipencopav opened 2 years ago
Found that a variable for holding the rest of the list is created in destructuring-bind
, but not used.
destructuring-bind
works well in this scenario, i don't know if there's a way to tell it to discard the rest of the list. If there is, then it's possible to do that, otherwise, maybe use a simpler LET form?
(defmacro doplist ((key val plist &optional rez) &body body)
"Like DOLIST but iterate over 2 items of the PLIST at once,
onsidered KEY and VAL. Asserts proper PLIST."
(once-only (plist)
(with-gensyms (tail)
`(progn
(do ((,tail ,plist (cddr ,tail)))
((null ,tail) ,rez)
(destructuring-bind (,key ,val &rest ,(gensym)) ,tail
; ^
; |
; here
,@body))))))
(defmacro doplist ((key val plist &optional rez) &body body)
"Like DOLIST but iterate over 2 items of the PLIST at once,
onsidered KEY and VAL. Asserts proper PLIST."
(rtl:once-only (plist)
(rtl:with-gensyms (tail)
`(progn
(do ((,tail ,plist (cddr ,tail)))
((null ,tail) ,rez)
(let ((,key (first ,tail))
(,val (second ,tail)))
,@body))))))
We only need to add (declare (ignorable ,rest))
. A fix has been proposed in PR #72 .
Code to reproduce:
Warning: