From 6d86a4367eb3ea3e7a33284c9f86cf06c01105be Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Mon, 6 May 2013 00:10:20 +0100 Subject: [PATCH] DOLIST and DOTIMES use extended lambda lists --- src/boot.lisp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) 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)))) -- 1.7.10.4