diff -urN release-tarballs/iterate-1.0.9/environments.lisp work/environments.lisp
--- release-tarballs/iterate-1.0.9/environments.lisp	1970-01-01 01:00:00.000000000 +0100
+++ work/environments.lisp	2004-11-15 20:52:50.000000000 +0100
@@ -0,0 +1,99 @@
+(in-package :iterate)
+
+(defclass our-environment ()
+     ((macros :initarg :macros :initform nil :accessor env-macros)
+      (functions :initarg :functions :initform nil :accessor env-functions)))
+
+(defvar *walker-environment* (make-instance 'our-environment))
+
+(defmacro with-rebound-macroexpand-hook (((expander form env)
+                                          &body new-hook-body) &body body)
+  `(let ((*macroexpand-hook* (lambda (,expander ,form ,env)
+                               ,@new-hook-body)))
+     ,@body))
+
+(defun is-defined-in (env slot name)
+  (find name (slot-value env slot) :key #'first))
+
+(defun augment-environment (env type name lambda-list body)
+  (assert (member type '(:function :macro)))
+  (labels ((frob (expected-type accessor)
+             (if (eql type expected-type)
+                 (let ((args (gensym "ARGS-"))
+                       (environ (gensym "ENV-")))
+                   (cons `(,name ,(if (eql type :macro)
+                                      (compile nil `(lambda (,args ,environ)
+                                                      (declare (ignore ,environ))
+                                                      (destructuring-bind ,lambda-list ,args
+                                                        ,@(walk-list body))))
+                                      nil))
+                       (funcall accessor env)))
+                 (remove name (funcall accessor env) :key #'first))))
+    (let ((functions (frob :function #'env-functions))
+          (macros (frob :macro #'env-macros)))
+      (make-instance 'our-environment
+         :macros macros
+         :functions functions))))
+
+(defmacro with-augmented-environment/env-part ((env type defns) &body body)
+  ;; XXX: better make sure that ENV is a special variable.
+  (let ((temp-env (gensym)))
+  `(let* ((,temp-env ,env)
+          (,env (progn
+                  (loop for (name lambda-list . thing-body) in ,defns
+                        do (setf ,temp-env (augment-environment ,temp-env ,type name lambda-list thing-body)))
+                  ,temp-env)))
+     ,@body)))
+
+(defmacro with-augmented-environment ((env type defns) &body body)
+  `(with-augmented-environment/env-part (,env ,type ,defns)
+     (with-rebound-macroexpand-hook ((expander form env)
+                                       (destructuring-bind (name &rest args) form
+                                         (declare (ignore args))
+                                         (cond
+                                           ((is-defined-in ,env 'functions name)
+                                            (values))
+                                           ((is-defined-in ,env 'macros name)
+                                            (multiple-value-bind (e-form expandedp) (walker-macroexpand form ,env)
+                                              (if expandedp
+                                                  e-form
+                                                  (values))))
+                                           (t
+                                            (funcall expander form env)))))
+       ,@body)))
+
+(defun walker-macro-function (symbol walker-env)
+  (unless (is-defined-in walker-env 'functions symbol)
+    (is-defined-in walker-env 'macros symbol)))
+
+
+(defun macro-function? (sym env walker-env)
+  (or
+   (and (not (macro-function sym env))
+        (is-defined-in walker-env 'macros sym))
+   (and (not (is-defined-in walker-env 'functions sym))
+        (macro-function sym env))))
+
+(defun walker-macroexpand (form walker-env)
+  (destructuring-bind (name &rest args) form
+    (let ((macro-defn (walker-macro-function name walker-env)))
+    (if macro-defn
+        (destructuring-bind (name macro-function) macro-defn
+          (declare (ignore name))
+          (values (funcall macro-function args walker-env) t))
+        (values form nil)))))
+
+(defun extended-macroexpand (form env walker-env)
+  (destructuring-bind (name &rest args) form
+    (declare (ignore args))
+    (cond
+      ((is-defined-in walker-env 'functions name)
+       (values form nil))
+      ((is-defined-in walker-env 'macros name)
+       (multiple-value-bind (e-form expandedp) (walker-macroexpand form walker-env)
+         (if expandedp
+             (values e-form t)
+             (values form nil))))
+      (t
+       (macroexpand form env)))))
+
diff -urN release-tarballs/iterate-1.0.9/iterate-test.lisp work/iterate-test.lisp
--- release-tarballs/iterate-1.0.9/iterate-test.lisp	2004-09-28 12:35:00.000000000 +0200
+++ work/iterate-test.lisp	2004-11-15 21:27:54.000000000 +0100
@@ -34,7 +34,7 @@
 (cl:defpackage #:iterate.test
   (:use #:cl #:iterate
 	#+sbcl #:sb-rt
-	#-sbcl #:rt))
+	#-sbcl #:regression-test))
 
 (cl:in-package #:iterate.test)
 
@@ -298,7 +298,6 @@
 	  (counting (oddp el)))
   3)
 
-
 ;;; FIXME: iterate::declare-variables seems to be ignored. leave it
 ;;; out?
 (deftest type.3
@@ -432,35 +431,29 @@
       (collect (multiple-value-prog1 7)))
   (7 7 7))
 
-;;; Tests for bugs. 
-;; when these start failing, I have done something right (-:
-(deftest bug/macrolet.1
-    (multiple-value-bind (_ error)
-	(ignore-errors
-	  (macroexpand '(iterate
-			 (repeat 10)
-			 (macrolet ((foo ()
-				      1))
-			   (collect (foo))))))
-      (declare (ignore _))
-      (not error))
+(deftest macrolet.1
+    (progn
+      (macroexpand '(iterate
+                     (repeat 10)
+                     (macrolet ((foo ()
+                                  1))
+                       (collect (foo)))))
+      nil)
   nil)
 
 ;; related to the above. hashtable iterators are specified to be
 ;; defined as symbol-macrolets
-(deftest bug/hashtable-walk.1
+(deftest hashtable-walk.1
     (let ((ht1 (make-hash-table))
           (ht2 (make-hash-table)))
       (setup-hash-table ht2)
       (setf (gethash 'a ht1) ht2)
-      (multiple-value-bind (_ error)
-          (ignore-errors
-            (macroexpand
-             '(iter (for (k1 v1) in-hashtable ht1)
-               (iter (for (k2 v2) in-hashtable ht2)
-                     (collect k2)))))
-        (declare (ignore _))
-        (not error)))
+      (progn
+        (macroexpand
+         '(iter (for (k1 v1) in-hashtable ht1)
+           (iter (for (k2 v2) in-hashtable ht2)
+                 (collect k2))))
+        nil))
   nil)
 
 ;;; arch-tag: "b8b1db2d-313c-11d8-abb9-000c76244c24"
diff -urN release-tarballs/iterate-1.0.9/iterate.asd work/iterate.asd
--- release-tarballs/iterate-1.0.9/iterate.asd	2004-09-28 12:35:00.000000000 +0200
+++ work/iterate.asd	2004-11-15 21:17:49.000000000 +0100
@@ -7,7 +7,8 @@
   
 (defsystem iterate
     :components ((:file "package")
-		 (:file "iterate" :depends-on ("package"))))
+                 (:file "environments")
+		 (:file "iterate" :depends-on ("package" "environments"))))
 
 (defsystem iterate-pg
     :depends-on (iterate pg)
diff -urN release-tarballs/iterate-1.0.9/iterate.lisp work/iterate.lisp
--- release-tarballs/iterate-1.0.9/iterate.lisp	2004-09-28 12:35:00.000000000 +0200
+++ work/iterate.lisp	2004-11-15 21:00:53.000000000 +0100
@@ -628,8 +628,11 @@
       ;; functions; and, by personal preference, special operators
       ;; should be expanded before iterate clauses.
 
-      ((macro-function (car form) *env*)
-       (walk (macroexpand form *env*)))
+      ((and (macro-function? (car form) *env* *walker-environment*)
+            ;; yay Allegro's macros that pose as special forms that
+            ;; pose as macros:
+            (nth-value 1 (extended-macroexpand form *env* *walker-environment*)))
+       (walk (extended-macroexpand form *env* *walker-environment*)))
       ((special-form? (car form))
        (walk-special-form form))
       ((starts-clause? (symbol-synonym (car form)))
@@ -902,7 +905,8 @@
     (multiple-value-bind (binds b-decls b-init b-step b-final b-finalp)
 	(walk-list-nconcing bindings #'walk-fspec #L(list !2))
       (multiple-value-bind (bod decls init step final finalp)
-	  (walk-list body)
+          (with-augmented-environment (*walker-environment* :function bindings)
+            (walk-list body))
 	(return-code :declarations b-decls
 		     :initial (nconc b-init init)
 		     :body (list `(,flet ,binds ,.decls ,.bod))
@@ -911,8 +915,17 @@
 		     :final-protected (nconc b-finalp finalp))))))
 
 
-(defun walk-macrolet (&rest stuff)
-  (macrolet-error stuff 'macrolet))
+(defun walk-macrolet (macrolet bindings &rest stuff)
+  (declare (ignore macrolet))
+  (multiple-value-bind (bod decls init step final finalp)
+      (with-augmented-environment (*walker-environment* :macro bindings)
+        (walk-list stuff))
+    (return-code :declarations decls
+                 :initial init
+                 :body `(,.decls ,.bod)
+                 :step step
+                 :final final
+                 :final-protected finalp)))
 
 (defun walk-symbol-macrolet (&rest stuff)
   (macrolet-error stuff 'symbol-macrolet))
@@ -967,8 +980,8 @@
 	    (let ((args (cons (keywordize (first ppclause))
 			      (cdr ppclause)))
 		  (func (clause-info-function info)))
-	      (if (macro-function func *env*)
-		  (walk (macroexpand (cons func args) *env*))
+	      (if (macro-function? func *env* *walker-environment*)
+		  (walk (extended-macroexpand (cons func args) *env* *walker-environment*))
 		  (apply-clause-function func args))))
 	   (t
 	    (clause-error "No iterate function for this clause; do ~
@@ -1903,7 +1916,7 @@
     nil)
    ((var-spec? template)
     (if bindings?
-	(make-default-binding template))
+        (make-default-binding template))
     `((setq ,(extract-var template) ,value)))
    ((not (listp template))
     (dsetq-error "Invalid binding form: ~a" template))
@@ -2024,8 +2037,8 @@
 	      (nconc free-vars (free-vars-list body bound-vars))))
 	(otherwise
 	    nil)))
-     ((macro-function (car form) *env*)
-      (free-vars (macroexpand form *env*) bound-vars))
+     ((macro-function? (car form) *env* *walker-environment*)
+      (free-vars (extended-macroexpand form *env* *walker-environment*) bound-vars))
      (t ; function call
       (free-vars-list (cdr form) bound-vars))))
    ((and (listp (car form)) (eq (caar form) 'lambda))
