From 9aec475196b69085d667016780bf57d31b59ce07 Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Tue, 20 Jun 2000 17:10:34 +0000 Subject: [PATCH] =?UTF-8?q?*=20session.scm=20(make-fold-modules):=20Detect?= =?UTF-8?q?=20circular=20references=20in=20module=20graph.=20=20(Thanks=20?= =?UTF-8?q?to=20Matthias=20K=C2=81=C3=B6ppe.)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ice-9/session.scm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ice-9/session.scm b/ice-9/session.scm index 5901eba23..208230938 100644 --- a/ice-9/session.scm +++ b/ice-9/session.scm @@ -264,12 +264,18 @@ The forest traversed is the image of the forest generated by root modules returned by INIT-THUNK and the generator TRAVERSE. It is an image under the mapping EXTRACT." (lambda (fold-module init) - (let rec ((data init) - (modules (init-thunk))) - (do ((modules modules (cdr modules)) - (data data (rec (fold-module (extract (car modules)) data) - (traverse (car modules))))) - ((null? modules) data))))) + (let* ((table (make-hash-table 31)) + (first? (lambda (obj) + (and (not (hash-ref table obj)) + (hash-create-handle! table obj #t))))) + (let rec ((data init) + (modules (init-thunk))) + (do ((modules modules (cdr modules)) + (data data (if (first? (car modules)) + (rec (fold-module (extract (car modules)) data) + (traverse (car modules))) + data))) + ((null? modules) data)))))) (define-public (apropos-fold-accessible module) (make-fold-modules (lambda () (list module))