From d5b1ca509e6888119702e75ce35cd1e55d295525 Mon Sep 17 00:00:00 2001 From: Julian Graham Date: Sat, 31 Oct 2009 13:02:13 -0400 Subject: [PATCH] Support for renaming bindings on module export. * module/ice-9/boot-9.scm (module-export!, module-replace!, module-re-export!): Allow members of export list to be pairs, mapping internal names to external ones. --- module/ice-9/boot-9.scm | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index 3d92fad..63f1493 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -3165,16 +3165,20 @@ module '(ice-9 q) '(make-q q-length))}." (define (module-export! m names) (let ((public-i (module-public-interface m))) (for-each (lambda (name) - (let ((var (module-ensure-local-variable! m name))) - (module-add! public-i name var))) + (let* ((internal-name (if (pair? name) (car name) name)) + (external-name (if (pair? name) (cdr name) name)) + (var (module-ensure-local-variable! m internal-name))) + (module-add! public-i external-name var))) names))) (define (module-replace! m names) (let ((public-i (module-public-interface m))) (for-each (lambda (name) - (let ((var (module-ensure-local-variable! m name))) + (let* ((internal-name (if (pair? name) (car name) name)) + (external-name (if (pair? name) (cdr name) name)) + (var (module-ensure-local-variable! m internal-name))) (set-object-property! var 'replace #t) - (module-add! public-i name var))) + (module-add! public-i external-name var))) names))) ;; Re-export a imported variable @@ -3182,13 +3186,15 @@ module '(ice-9 q) '(make-q q-length))}." (define (module-re-export! m names) (let ((public-i (module-public-interface m))) (for-each (lambda (name) - (let ((var (module-variable m name))) + (let* ((internal-name (if (pair? name) (car name) name)) + (external-name (if (pair? name) (cdr name) name)) + (var (module-variable m internal-name))) (cond ((not var) - (error "Undefined variable:" name)) - ((eq? var (module-local-variable m name)) - (error "re-exporting local variable:" name)) + (error "Undefined variable:" internal-name)) + ((eq? var (module-local-variable m internal-name)) + (error "re-exporting local variable:" internal-name)) (else - (module-add! public-i name var))))) + (module-add! public-i external-name var))))) names))) (defmacro export names -- 1.6.0.4