[go: up one dir, main page]

Menu

[1aafb6]: / scheme / reexport.scm  Maximize  Restore  History

Download this file

27 lines (23 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
;; From thi's THUD --10/20/99 gjb
;; Re-export variables from module named OTHER-MODULE-NAME. If SPECIFICALLY
;; is the empty list, all public variables from OTHER-MODULE-NAME are
;; exported, otherwise, each element in SPECIFICALLY is taken to be either a
;; symbol naming a variable to be exported, or a pair of symbols of the form
;; (OLD-NAME . NEW-NAME) describing the mapping to be used. OLD-NAME should
;; name an exported variable in OTHER-MODULE-NAME.
;;
;; (defmacro reexport-from-module (other-module-name . specifically)
;; `(let ((cur-mod (current-module))
;; (other-mod (resolve-module ',other-module-name))
;; (spec (map (lambda (x) (if (pair? x) x (cons x x))) ; for assq
;; ',specifically)))
;; (let ((add! (lambda (old-name new-name)
;; (module-add! (module-public-interface cur-mod)
;; new-name
;; (module-variable other-mod old-name)))))
;; (module-map (lambda (sym x)
;; (if (eq? '() spec)
;; (add! sym sym)
;; (let ((try (assq sym spec)))
;; (and try (add! (car try) (cdr try))))))
;; (module-public-interface other-mod)))))