summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-11-18 21:48:55 +0100
committerAndy Wingo <wingo@pobox.com>2010-11-18 21:48:55 +0100
commitc9b16ceef7fe382aef3c4d236bdc83901d55d18d (patch)
treef43887fdb6198e290475ed0b2d85ace33c2c42b0
parent3740c788ac67f7867ef41165380cff877666d219 (diff)
downloadguile-c9b16ceef7fe382aef3c4d236bdc83901d55d18d.tar.gz
add `reload-module' to boot-9
* module/ice-9/boot-9.scm (reload-module): New procedure, programmatically reloads the source file corresponding to the given module.
-rw-r--r--module/ice-9/boot-9.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index b3b689345..24ce62136 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -2252,6 +2252,18 @@ If there is no handler at all, Guile prints an error and then exits."
(define (try-load-module name version)
(try-module-autoload name version))
+(define (reload-module m)
+ (let ((f (module-filename m)))
+ (if f
+ (save-module-excursion
+ (lambda ()
+ ;; Re-set the initial environment, as in try-module-autoload.
+ (set-current-module (make-fresh-user-module))
+ (primitive-load-path f)
+ m))
+ ;; Though we could guess, we *should* know it.
+ (error "unknown file name for module" m))))
+
(define (purify-module! module)
"Removes bindings in MODULE which are inherited from the (guile) module."
(let ((use-list (module-uses module)))