guile-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guile/guile-core/ice-9 boot-9.scm


From: Marius Vollmer
Subject: guile/guile-core/ice-9 boot-9.scm
Date: Mon, 04 Jun 2001 15:14:16 -0700

CVSROOT:        /cvs
Module name:    guile
Changes by:     Marius Vollmer <address@hidden> 01/06/04 15:14:16

Modified files:
        guile-core/ice-9: boot-9.scm 

Log message:
        (module-ensure-local-variable!): Renamed from
        `module-ensure-variable!'.  Make sure that there really is a local
        variable, not just a visible one.
        (module-ensure-variable!): See above.
        (module-export!): Behave like always when deprecated features are
        enabled, but issue a warning when re-exporting a variable.  When
        deprecated features are disabled, only export local variables,
        creating them uninitialized when they don't yet exist.
        (module-re-export!): New.  Use this for re-exporting imported
        variables.
        (re-export): New, to go with `module-re-export!'.
        
        (named-module-use!, top-repl): Use resolve-interface
        instead of resolve-module to get at the used module.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile-core/ice-9/boot-9.scm.diff?cvsroot=OldCVS&tr1=1.259&tr2=1.260&r1=text&r2=text

Patches:
Index: guile/guile-core/ice-9/boot-9.scm
diff -u guile/guile-core/ice-9/boot-9.scm:1.259 
guile/guile-core/ice-9/boot-9.scm:1.260
--- guile/guile-core/ice-9/boot-9.scm:1.259     Sun Jun  3 16:29:45 2001
+++ guile/guile-core/ice-9/boot-9.scm   Mon Jun  4 15:14:16 2001
@@ -1280,17 +1280,14 @@
          (module-modified m)
          answer))))
 
-;; module-ensure-variable! module symbol
+;; module-ensure-local-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.
+;; 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.
 ;;
-;; (This is not a really clean thing to do, we should evetually get
-;; rid of the need for `module-ensure-variable!')
-;;
-(define (module-ensure-variable! module symbol)
-  (or (module-variable module symbol)
+(define (module-ensure-local-variable! module symbol)
+  (or (module-local-variable module symbol)
       (let ((var (make-undefined-variable)))
        (variable-set-name-hint! var symbol)
        (module-add! module symbol var)
@@ -2780,13 +2777,38 @@
         (eval-case ((load-toplevel) (export ,name)))
         (defmacro ,@args))))))
 
+;; Export a local variable
+;;
 (define (module-export! m names)
   (let ((public-i (module-public-interface m)))
+    (for-each (lambda (name)
+               (begin-deprecated
+                (if (not (module-local-variable m name))
+                    (let ((v (module-variable m name)))
+                      (cond 
+                       (v
+                        (issue-deprecation-warning
+                         "Using `export' to re-export imported bindings is 
deprecated.  Use `re-export' instead.")
+                        (issue-deprecation-warning
+                         (simple-format #f "(You just re-exported `~a' from 
`~a'.)"
+                                        name (module-name m)))
+                        (module-define! m name (variable-ref v)))))))
+               (let ((var (module-ensure-local-variable! m name)))
+                 (module-add! public-i name var)))
+             names)))
+
+;; Re-export a imported variable
+;;
+(define (module-re-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-variable m name)))
+                 (cond ((not var)
+                        (error "Undefined variable:" name))
+                       ((eq? var (module-local-variable m name))
+                        (error "re-exporting local variable:" name))
+                       (else
+                        (module-add! public-i name var)))))
              names)))
 
 (defmacro export names
@@ -2796,6 +2818,13 @@
     (else
      (error "export can only be used at the top level"))))
 
+(defmacro re-export names
+  `(eval-case
+    ((load-toplevel)
+     (module-re-export! (current-module) ',names))
+    (else
+     (error "re-export can only be used at the top level"))))
+
 (define export-syntax export)
 
 
@@ -2933,7 +2962,7 @@
 ;;; {Load emacs interface support if emacs option is given.}
 
 (define (named-module-use! user usee)
-  (module-use! (resolve-module user) (resolve-module usee)))
+  (module-use! (resolve-module user) (resolve-interface usee)))
 
 (define (load-emacs-interface)
   (and (provided? 'debug-extensions)
@@ -2959,17 +2988,17 @@
     ;; Use some convenient modules (in reverse order)
     
     (if (provided? 'regex)
-       (module-use! guile-user-module (resolve-module '(ice-9 regex))))
+       (module-use! guile-user-module (resolve-interface '(ice-9 regex))))
     (if (provided? 'threads)
-       (module-use! guile-user-module (resolve-module '(ice-9 threads))))
+       (module-use! guile-user-module (resolve-interface '(ice-9 threads))))
     ;; load debugger on demand
     (module-use! guile-user-module 
                 (make-autoload-interface guile-user-module
                                          '(ice-9 debugger) '(debug)))
-    (module-use! guile-user-module (resolve-module '(ice-9 session)))
-    (module-use! guile-user-module (resolve-module '(ice-9 debug)))
+    (module-use! guile-user-module (resolve-interface '(ice-9 session)))
+    (module-use! guile-user-module (resolve-interface '(ice-9 debug)))
     ;; so that builtin bindings will be checked first
-    (module-use! guile-user-module (resolve-module '(guile))) 
+    (module-use! guile-user-module (resolve-interface '(guile)))
 
     (set-current-module guile-user-module)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]