(module-ensure-variable!): New.
authorMarius Vollmer <mvo@zagadka.de>
Sat, 2 Jun 2001 18:33:25 +0000 (18:33 +0000)
committerMarius Vollmer <mvo@zagadka.de>
Sat, 2 Jun 2001 18:33:25 +0000 (18:33 +0000)
(module-export!): Use it to ensure that there is a variable to
export.  Previously, we would always create a new variable, copy
the value over, and export the new variable.  This confused
syncase since it keys important properties on variables.

ice-9/boot-9.scm

index 644c827..72d3e6d 100644 (file)
          (module-modified m)
          answer))))
 
+;; module-ensure-variable! module symbol
+;;
+;; ensure that there is a variable in MODULE for SYMBOL.  If there is
+;; no binding for SYMBOL, create a new undefined variable.  Return
+;; that variable.
+;;
+(define (module-ensure-variable! module symbol)
+  (or (module-variable module symbol)
+      (let ((var (make-undefined-variable)))
+       (variable-set-name-hint! var symbol)
+       (module-add! module symbol var)
+       var)))
+
 ;; module-add! module symbol var
 ;;
 ;; ensure a particular variable for V in the local namespace of M.
 (define (module-export! m names)
   (let ((public-i (module-public-interface m)))
     (for-each (lambda (name)
-               ;; Make sure there is a local variable:
-               (module-define! m name (module-ref m name #f))
-               ;; Make sure that local is exported:
-               (module-add! public-i name (module-variable m name)))
+               (let ((var (module-ensure-variable! m name)))
+                 (module-add! public-i name var)))
              names)))
 
 (defmacro export names