From 81fc66cfb665814d9cfd766b3c19be90ae1b13ec Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 23 Apr 2010 16:31:09 +0200 Subject: [PATCH] add submodule binders * module/ice-9/boot-9.scm (module-submodule-binder) (set-module-submodule-binder!): New field on modules. (make-module, make-autoload-interface): Adapt. (module-ref-submodule): If we miss the submodules table, call the submodules binder, if any. * module/ice-9/deprecated.scm (module-ref-submodule): Check the submodule binder before the deprecated look into the obarray. --- module/ice-9/boot-9.scm | 11 +++++++---- module/ice-9/deprecated.scm | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index bc9f170ca..3dcc8d90f 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -1566,7 +1566,8 @@ If there is no handler at all, Guile prints an error and then exits." observers (weak-observers #:no-setter) version - submodules))) + submodules + submodule-binder))) ;; make-module &opt size uses binder @@ -1608,7 +1609,7 @@ If there is no handler at all, Guile prints an error and then exits." (make-hash-table %default-import-size) '() (make-weak-key-hash-table 31) #f - (make-hash-table 7)))) + (make-hash-table 7) #f))) ;; We can't pass this as an argument to module-constructor, ;; because we need it to close over a pointer to the module @@ -1925,7 +1926,9 @@ If there is no handler at all, Guile prints an error and then exits." ;; with local variables that happen to be named the same as the submodule. ;; (define (module-ref-submodule module name) - (hashq-ref (module-submodules module) name)) + (or (hashq-ref (module-submodules module) name) + (and (module-submodule-binder module) + ((module-submodule-binder module) module name)))) (define (module-define-submodule! module name submodule) (hashq-set! (module-submodules module) name submodule)) @@ -2681,7 +2684,7 @@ If there is no handler at all, Guile prints an error and then exits." (module-local-variable i sym)))))) (module-constructor (make-hash-table 0) '() b #f #f name 'autoload #f (make-hash-table 0) '() (make-weak-value-hash-table 31) #f - (make-hash-table 0)))) + (make-hash-table 0) #f))) (define (module-autoload! module . args) "Have @var{module} automatically load the module named @var{name} when one diff --git a/module/ice-9/deprecated.scm b/module/ice-9/deprecated.scm index c6dab4e93..15e245d1a 100644 --- a/module/ice-9/deprecated.scm +++ b/module/ice-9/deprecated.scm @@ -302,6 +302,8 @@ (define (module-ref-submodule module name) (or (hashq-ref (module-submodules module) name) + (and (module-submodule-binder module) + ((module-submodule-binder module) module name)) (let ((var (module-local-variable module name))) (and (variable-bound? var) (module? (variable-ref var)) -- 2.20.1