add module-ref-submodule, module-define-submodule!
authorAndy Wingo <wingo@pobox.com>
Fri, 23 Apr 2010 13:37:36 +0000 (15:37 +0200)
committerAndy Wingo <wingo@pobox.com>
Fri, 23 Apr 2010 14:14:31 +0000 (16:14 +0200)
* module/ice-9/boot-9.scm (module-ref-submodule):
  (module-define-submodule!): New stubs, will be used to separate
  traversing the module tree from accessing values.

module/ice-9/boot-9.scm

index 9f9a9d3..5f2da30 100644 (file)
@@ -1916,6 +1916,20 @@ If there is no handler at all, Guile prints an error and then exits."
 (define (module-map proc module)
   (hash-map->list proc (module-obarray module)))
 
+;; Submodules
+;;
+;; Modules exist in a separate namespace from values, because you generally do
+;; not want the name of a submodule, which you might not even use, to collide
+;; with local variables that happen to be named the same as the submodule.
+;;
+(define (module-ref-submodule module name)
+  (let ((m (module-ref module name)))
+    (and m (module? m) m)))
+
+(define (module-define-submodule! module name submodule)
+  (module-define! module name submodule))
+
+
 \f
 
 ;;; {Low Level Bootstrapping}