From: David Vázquez Date: Sun, 5 May 2013 23:10:20 +0000 (+0100) Subject: DOLIST and DOTIMES use extended lambda lists X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=6d86a4367eb3ea3e7a33284c9f86cf06c01105be;p=jscl.git DOLIST and DOTIMES use extended lambda lists --- diff --git a/src/boot.lisp b/src/boot.lisp index d2bb0c1..8c1d6c2 100644 --- a/src/boot.lisp +++ b/src/boot.lisp @@ -139,27 +139,25 @@ ,@(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))))