From 53f84bc8b55efb648e181ded6b973ea87d32d026 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Tue, 2 Sep 2008 00:40:57 -0700 Subject: [PATCH] prevent (resolve-module '(guile)) recursion * ice-9/boot-9.scm (resolve-module): Change so that resolving '(guile) does not require any module lookups. This is so that while within a call to (resolve-module '(guile)), we don't recurse when looking up the location for e.g. `append'. I can imagine other ways to get around this, but this one seems OK. --- ice-9/boot-9.scm | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index 9a7ff3bf5..f1aedc277 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -1826,25 +1826,29 @@ ;; NOTE: This binding is used in libguile/modules.c. ;; -(define (resolve-module name . maybe-autoload) - (let ((full-name (append '(%app modules) name))) - (let ((already (nested-ref the-root-module full-name))) - (if already - ;; The module already exists... - (if (and (or (null? maybe-autoload) (car maybe-autoload)) - (not (module-public-interface already))) - ;; ...but we are told to load and it doesn't contain source, so - (begin - (try-load-module name) - already) - ;; simply return it. - already) - (begin - ;; Try to autoload it if we are told so - (if (or (null? maybe-autoload) (car maybe-autoload)) - (try-load-module name)) - ;; Get/create it. - (make-modules-in (current-module) full-name)))))) +(define resolve-module + (let ((the-root-module the-root-module)) + (lambda (name . maybe-autoload) + (if (equal? name '(guile)) + the-root-module + (let ((full-name (append '(%app modules) name))) + (let ((already (nested-ref the-root-module full-name))) + (if already + ;; The module already exists... + (if (and (or (null? maybe-autoload) (car maybe-autoload)) + (not (module-public-interface already))) + ;; ...but we are told to load and it doesn't contain source, so + (begin + (try-load-module name) + already) + ;; simply return it. + already) + (begin + ;; Try to autoload it if we are told so + (if (or (null? maybe-autoload) (car maybe-autoload)) + (try-load-module name)) + ;; Get/create it. + (make-modules-in (current-module) full-name))))))))) ;; Cheat. These bindings are needed by modules.c, but we don't want ;; to move their real definition here because that would be unnatural.