The issue is really not a show-stopper. I am raising it as fixing it eliminates an unexpected error that may throw off a user. Also, dolist accepts declare forms. So should then dotable
The following code (adapted from the tutorial):
(let ((rez ()))
(dotable (k v #h(1 :foo 2 :bar) rez)
(declare (ignore v))
(when (oddp k)
(push k rez))))
does not compile because in the macro-expansion a NIL is inserted by the ,(when '(declare (ignore )) form. When _ is nil, when returns nil and the declaration is placed incorrectly:
(DOLIST (#:G11537 #:TABLE11538)
(DESTRUCTURING-BIND
(K . V)
#:G11537
NIL ; generated by the when form
(DECLARE (IGNORE V))
(WHEN (ODDP K) (PUSH K REZ))))
To avoid generating the NIL, the when form needs to be written like so:
,@(when _ `((declare (ignore _)))
Note the @ and the extra parenthesis around declare.
This whole problem can and should be avoided by using the _ underscore, eliminating the need for the user to use declare.
Again, I raise this, as it raises an error whereas dolist would not issue one.
The issue is really not a show-stopper. I am raising it as fixing it eliminates an unexpected error that may throw off a user. Also,
dolist
acceptsdeclare
forms. So should thendotable
The following code (adapted from the tutorial):
does not compile because in the macro-expansion a NIL is inserted by the ,(when '(declare (ignore )) form. When
_
is nil,when
returnsnil
and the declaration is placed incorrectly:To avoid generating the
NIL
, the when form needs to be written like so:Note the
@
and the extra parenthesis arounddeclare
.This whole problem can and should be avoided by using the _ underscore, eliminating the need for the user to use declare.
Again, I raise this, as it raises an error whereas dolist would not issue one.