,@(cdr newval))
,setter))))
-(defmacro dolist (iter &body body)
- (let ((var (first iter))
- (g!list (gensym)))
+(defmacro dolist ((var list &optional result) &body body)
+ (let ((g!list (gensym)))
+ (unless (symbolp var) (error "`~S' is not a symbol." var))
`(block nil
- (let ((,g!list ,(second iter))
+ (let ((,g!list ,list)
(,var nil))
(%while ,g!list
(setq ,var (car ,g!list))
(tagbody ,@body)
(setq ,g!list (cdr ,g!list)))
- ,(third iter)))))
+ ,result))))
-(defmacro dotimes (iter &body body)
- (let ((g!to (gensym))
- (var (first iter))
- (to (second iter))
- (result (third iter)))
+(defmacro dotimes ((var count &optional result) &body body)
+ (let ((g!count (gensym)))
+ (unless (symbolp var) (error "`~S' is not a symbol." var))
`(block nil
(let ((,var 0)
- (,g!to ,to))
- (%while (< ,var ,g!to)
+ (,g!count ,count))
+ (%while (< ,var ,g!count)
(tagbody ,@body)
(incf ,var))
,result))))