\(fn (VAR COUNT [RESULT]) BODY...)"
(declare (indent 1) (debug dolist))
- (let ((var (nth 0 spec))
- (end (nth 1 spec))
- (upper-bound (make-symbol "upper-bound"))
+ (let ((upper-bound (make-symbol "upper-bound"))
(counter (make-symbol "counter")))
- `(let ((,upper-bound ,end)
- (,counter 0))
- (while (< ,counter ,upper-bound)
- (let ((,var ,counter))
- ,@body)
- (setq ,counter (1+ ,counter)))
- ,@(if (cddr spec)
- ;; FIXME: This let often leads to "unused var" warnings.
- `((let ((,var ,counter)) ,@(cddr spec)))))))
+ (if (consp spec)
+ (let ((var (nth 0 spec))
+ (end (nth 1 spec)))
+ `(let ((,upper-bound ,end)
+ (,counter 0))
+ (while (< ,counter ,upper-bound)
+ (let ((,var ,counter))
+ ,@body)
+ (setq ,counter (1+ ,counter)))
+ ,@(if (cddr spec)
+ ;; FIXME: This let often leads to "unused var" warnings.
+ `((let ((,var ,counter)) ,@(cddr spec))))))
+ ;; `spec' is a number.
+ `(let ((,upper-bound ,spec)
+ (,counter 0))
+ (while (< ,counter ,upper-bound)
+ ,@body
+ (setq ,counter (1+ ,counter)))))))
(defmacro declare (&rest specs)
"Do not evaluate any arguments, and return nil.