From 9540368e79ea7c20c2262e78478ea95fa34819c8 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 2 Jun 2001 18:33:25 +0000 Subject: [PATCH] (module-ensure-variable!): New. (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 | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index 644c82725..72d3e6d57 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -1256,6 +1256,19 @@ (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. @@ -2745,10 +2758,8 @@ (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