# HG changeset patch # User Richard M. Stallman # Date 948425892 0 # Node ID b1b3e778f7acd862ab8ceb15191166da731c5b18 # Parent f2499774f43c14260423154ce9e8de6a67551622 Make the definitions of dolist and dotimes work without the rest of CL. diff -r f2499774f43c -r b1b3e778f7ac lisp/subr.el --- a/lisp/subr.el Fri Jan 21 03:37:07 2000 +0000 +++ b/lisp/subr.el Fri Jan 21 03:38:12 2000 +0000 @@ -82,27 +82,31 @@ "(dolist (VAR LIST [RESULT]) BODY...): loop over a list. Evaluate BODY with VAR bound to each car from LIST, in turn. Then evaluate RESULT to get return value, default nil." - (let ((temp (gensym "--dolist-temp--"))) - (list 'block nil - (list* 'let (list (list temp (nth 1 spec)) (car spec)) - (list* 'while temp (list 'setq (car spec) (list 'car temp)) - (append body (list (list 'setq temp - (list 'cdr temp))))) - (if (cdr (cdr spec)) - (cons (list 'setq (car spec) nil) (cdr (cdr spec))) - '(nil)))))) + (let ((temp (make-symbol "--dolist-temp--"))) + (list 'let (list (list temp (nth 1 spec)) (car spec)) + (list 'while temp + (list 'setq (car spec) (list 'car temp)) + (cons 'progn + (append body + (list (list 'setq temp (list 'cdr temp)))))) + (if (cdr (cdr spec)) + (cons 'progn + (cons (list 'setq (car spec) nil) (cdr (cdr spec)))))))) (defmacro dotimes (spec &rest body) "(dotimes (VAR COUNT [RESULT]) BODY...): loop a certain number of times. Evaluate BODY with VAR bound to successive integers running from 0, inclusive, to COUNT, exclusive. Then evaluate RESULT to get the return value (nil if RESULT is omitted)." - (let ((temp (gensym "--dotimes-temp--"))) - (list 'block nil - (list* 'let (list (list temp (nth 1 spec)) (list (car spec) 0)) - (list* 'while (list '< (car spec) temp) - (append body (list (list 'incf (car spec))))) - (or (cdr (cdr spec)) '(nil)))))) + (let ((temp (make-symbol "--dotimes-temp--"))) + (list 'let (list (list temp (nth 1 spec)) (list (car spec) 0)) + (list 'while (list '< (car spec) temp) + (cons 'progn + (append body (list (list 'setq (car spec) + (list '1+ (car spec))))))) + (if (cdr (cdr spec)) + (car (cdr (cdr spec))) + nil)))) (defsubst caar (x) "Return the car of the car of X."