[cl-typesetting-devel] Iterate patch

Peter Seibel peter at javamonkey.com
Wed Nov 10 05:01:25 UTC 2004


So the problem I mentioned with iterate.lisp and Allegro 7.0 seems to
be something that could arguably be considered a bug in ITERATE. At
any rate it's not going to be fixed in Allegro any time soon. This
patch fixes it. Also that problem I had with running out of memory
when generating a 400+ page document in Allegro 6.2 went away in 7.0
for whatever that's worth.

-Peter


Index: iterate/iterate.lisp
===================================================================
--- iterate/iterate.lisp	(revision 66)
+++ iterate/iterate.lisp	(working copy)
@@ -627,7 +627,7 @@
       ;; functions; and, by personal preference, special operators
       ;; should be expanded before iterate clauses.
 
-      ((macro-function (car form) *env*)
+      ((macro-form? (car form) *env*)
        (walk (macroexpand form *env*)))
       ((special-form? (car form))
        (walk-special-form form))
@@ -727,6 +727,16 @@
   (or (special-operator-p symbol)
       (assoc symbol *special-form-alist*)))
 
+(defun macro-form? (symbol &optional env)
+  ;; Workaround to deal with Allegro 7.0 where DECLARE has a
+  ;; MACRO-FUNCTION but MACROEXPANDING it goes into an infinite loop.
+  ;; Arguably this is rightous in any implementation because a DECLARE
+  ;; expression is not a form and MACROEXPAND's argumnet is supposed
+  ;; to be a form.
+  (when (not (eql symbol 'cl:declare))
+    (macro-function symbol env)))
+
+
 (defun walk-special-form (form)
   (let* ((*clause* form)
 	 (func-p (assoc (car form) *special-form-alist*))
@@ -963,7 +973,7 @@
 	    (let ((args (cons (keywordize (first ppclause))
 			      (cdr ppclause)))
 		  (func (clause-info-function info)))
-	      (if (macro-function func *env*)
+	      (if (macro-form? func *env*)
 		  (walk (macroexpand (cons func args) *env*))
 		  (apply-clause-function func args))))
 	   (t
@@ -2020,7 +2030,7 @@
 	      (nconc free-vars (free-vars-list body bound-vars))))
 	(otherwise
 	    nil)))
-     ((macro-function (car form) *env*)
+     ((macro-form? (car form) *env*)
       (free-vars (macroexpand form *env*) bound-vars))
      (t ; function call
       (free-vars-list (cdr form) bound-vars))))

-- 
Peter Seibel                                      peter at javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp




More information about the cl-typesetting-devel mailing list