on is used in modules.c.
;;
(define (module-make-local-var! m v)
  "Ensure a variable for V in the local namespace of M.
If no variable was already there, then create a new and uninitialized
variable."
  (or (let ((b (module-obarray-ref (module-obarray m) v)))
        (and (variable? b)
             (begin
               ;; Mark as modified since this function is called when
               ;; the standard eval closure defines a binding
               (module-modified m)
               b)))

      ;; Create a new local variable.
      (let ((local-var (make-undefined-variable)))
        (module-add! m v local-var)
        local-var)))

(define (module-ensure-local-variable! module symbol)
  "Ensure that there is a local variable in MODULE for SYMBOL.  If
there is no binding for SYMBOL, create a new uninitialized
variable.  Return the local variable."
  (or (module-local-variable module symbol)
      (let ((var (make-undefined-variable)))
        (module-add! module symbol var)
        var)))

;; module-add! module symbol var
;;
(define (module-add! m v var)
  "Ensure a particular variable for V in the local namespace of M."
  (if (not (variable? var))
      (error "Bad variable to module-add!" var))
  (if (not (symbol? v))
      (error "Bad symbol to module-add!" v))
  (module-obarray-set! (module-obarray m) v var)
  (module-modified m))

(define (module-remove! m v)
  "Make sure that symbol V is undefined in the local namespace of M."
  (module-obarray-remove! (module-obarray m) v)
  (module-modified m))

(define (module-clear! m)
  (hash-clear! (module-obarray m))
  (module-modified m))

;; MODULE-FOR-EACH -- exported
;;
(define (module-for-each proc module)
  "Call PROC on each symbol in MODULE, with arguments of (SYMBOL VARIABLE)."
  (hash-for-each proc (module-obarray module)))

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

