1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-30 06:50:31 +02:00

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.
This commit is contained in:
Andy Wingo 2010-04-23 16:31:09 +02:00
parent f6a5308b03
commit 81fc66cfb6
2 changed files with 9 additions and 4 deletions

View file

@ -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

View file

@ -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))