X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fdefboot.lisp;h=149997fced65bcb2f612444836361d7c54664058;hb=f9aaac53a4a43ebae198f53079857acb2d628eb0;hp=440fe2d8a2676ce55d06b529169d30595031d070;hpb=ff57884e206ac28660af6af34315bc9b81697f57;p=sbcl.git diff --git a/src/code/defboot.lisp b/src/code/defboot.lisp index 440fe2d..149997f 100644 --- a/src/code/defboot.lisp +++ b/src/code/defboot.lisp @@ -105,19 +105,17 @@ ;;;; various sequencing constructs -(defmacro-mundanely prog (varlist &body body-decls) - (multiple-value-bind (body decls) (parse-body body-decls nil) - `(block nil - (let ,varlist - ,@decls - (tagbody ,@body))))) - -(defmacro-mundanely prog* (varlist &body body-decls) - (multiple-value-bind (body decls) (parse-body body-decls nil) - `(block nil - (let* ,varlist - ,@decls - (tagbody ,@body))))) +(flet ((prog-expansion-from-let (varlist body-decls let) + (multiple-value-bind (body decls) + (parse-body body-decls :doc-string-allowed nil) + `(block nil + (,let ,varlist + ,@decls + (tagbody ,@body)))))) + (defmacro-mundanely prog (varlist &body body-decls) + (prog-expansion-from-let varlist body-decls 'let)) + (defmacro-mundanely prog* (varlist &body body-decls) + (prog-expansion-from-let varlist body-decls 'let*))) (defmacro-mundanely prog1 (result &body body) (let ((n-result (gensym))) @@ -287,14 +285,14 @@ (defmacro-mundanely dotimes ((var count &optional (result nil)) &body body) (cond ((numberp count) `(do ((,var 0 (1+ ,var))) - ((>= ,var ,count) ,result) - (declare (type unsigned-byte ,var)) - ,@body)) + ((>= ,var ,count) ,result) + (declare (type unsigned-byte ,var)) + ,@body)) (t (let ((v1 (gensym))) `(do ((,var 0 (1+ ,var)) (,v1 ,count)) - ((>= ,var ,v1) ,result) - (declare (type unsigned-byte ,var)) - ,@body))))) + ((>= ,var ,v1) ,result) + (declare (type unsigned-byte ,var)) + ,@body))))) (defmacro-mundanely dolist ((var list &optional (result nil)) &body body) ;; We repeatedly bind the var instead of setting it so that we never @@ -305,19 +303,24 @@ ;; environment. We spuriously reference the gratuitous variable, ;; since we don't want to use IGNORABLE on what might be a special ;; var. - (multiple-value-bind (forms decls) (parse-body body nil) - (let ((n-list (gensym))) - `(do* ((,n-list ,list (cdr ,n-list))) - ((endp ,n-list) - ,@(if result - `((let ((,var nil)) - ,var - ,result)) - '(nil))) - (let ((,var (car ,n-list))) - ,@decls - (tagbody - ,@forms)))))) + (multiple-value-bind (forms decls) (parse-body body :doc-string-allowed nil) + (let ((n-list (gensym "N-LIST")) + (start (gensym "START"))) + `(block nil + (let ((,n-list ,list)) + (tagbody + ,start + (unless (endp ,n-list) + (let ((,var (car ,n-list))) + ,@decls + (setq ,n-list (cdr ,n-list)) + (tagbody ,@forms)) + (go ,start)))) + ,(if result + `(let ((,var nil)) + ,var + ,result) + nil))))) ;;;; conditions, handlers, restarts @@ -385,7 +388,7 @@ ,n-cond (car *restart-clusters*) ,(if (eq name 'cerror) - `(cerror ,(second expression) ,n-cond) + `(cerror ,(second exp) ,n-cond) `(,name ,n-cond)))) expression)) expression))) @@ -581,10 +584,8 @@ `(let ((,(caaddr annotated-case) ,var)) ,@body)) - ((not (cdr body)) - (car body)) (t - `(progn ,@body))))))) + `(locally ,@body))))))) annotated-cases)))))))) ;;;; miscellaneous