[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] Re: Using a container module to export bindings from a
From: |
felix |
Subject: |
[Chicken-hackers] Re: Using a container module to export bindings from a group of related modules |
Date: |
Thu, 22 Oct 2009 09:58:33 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Tony Sidaway <tonysidaway <at> gmail.com> writes:
> Something simple like
>
> (export ... (module IDENTIFIER...) ...)
>
See also "reexport". Note that it needs a bugfix that is not yet integrated into
the mainline (a patch follows).
cheers,
felix
--
diff --git a/expand.scm b/expand.scm
index 1e8b0b5..58eefae 100644
--- a/expand.scm
+++ b/expand.scm
@@ -879,15 +879,19 @@
(lambda (spec)
(let* ((vs (import-spec spec))
(vsv (car vs))
- (vss (cdr vs)))
+ (vss (cdr vs))
+ (prims '()))
(dd `(IMPORT: ,loc))
(dd `(V: ,(if cm (module-name cm) '<toplevel>) ,(map-se vsv)))
(dd `(S: ,(if cm (module-name cm) '<toplevel>) ,(map-se vss)))
(##sys#mark-imported-symbols vsv) ; mark imports as ##core#aliased
(for-each
(lambda (imp)
- (let ((id (car imp))
- (aid (cdr imp)))
+ (let* ((id (car imp))
+ (aid (cdr imp))
+ (prim (##sys#get aid '##core#primitive)))
+ (when prim
+ (set! prims (cons imp prims)))
(and-let* ((a (assq id (import-env)))
((not (eq? aid (cdr a)))))
(##sys#warn "re-importing already imported identifier" id))))
@@ -907,12 +911,23 @@
(module-export-list cm)
(map car vsv)
(map car vss)))
+ (when (pair? prims)
+ (set-module-meta-expressions!
+ cm
+ (append
+ (module-meta-expressions cm)
+ `((##sys#mark-primitive ',prims)))))
(dm "export-list: " (module-export-list cm)))
(import-env (append vsv (import-env)))
(macro-env (append vss (macro-env)))))
(cdr x))
'(##core#undefined))))
+(define (##sys#mark-primitive prims)
+ (for-each
+ (lambda (a) (##sys#put! (cdr a) '##core#primitive (car a)))
+ prims))
+
(##sys#extend-macro-environment
'import '()
(##sys#er-transformer