<cl> (dolist (x '(a b c)) (print x)) A B C NIL <cl> (dotimes (x 3) (print x)) 0 1 2 NIL <cl> (do ((x 1 (+ x 2))) ((> x 3) x) (print x)) 1 3 5 <cl> x Error: Attempt to take the value of the unbound symbol X [1] <cl> :reset繰り返しの内部で使われる変数(ここでは x)は局所変数で, この内部だけで値を持つものです.外側のxとは別のものです. dotimesを定義してみると,
(defmacro dotimes ((var form &optional (result nil)) &body) (let ((limit (gensym))) `(do ((,var 0 (1+ ,var)) (,limit ,form)) ((>= ,var ,limit) result) ,@body)))とできます.ここで,dotimesが
(dotimes (変数 整数式 結果) 本体)という形で,結果があってもなくてもよいために,
((変数 整数式 &optional) . 本体)という形で引数宣言がなされています.