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

# modules solution

```(herald modules (env t))

; Modules as defined below can be translated into
; labels statements. [* means 0 or more occurences].

; (modules (<module-definition>*) (<imported-name>*) . <body>)
; <body> = same as what goes in a block.
; <module-definition> = (<module-name> <export-list> (<imported-name>*)
;                             . <labels-spec>*)
; <imported-name> = (<local-name> <module-name> <name-in-module>)
; <labels-spec> = the definitions in T labels.

; Example: here is an expression with two modules.
; The symbols with double colon should really be made with gen-id!

; (modules   ; defines two modules, z and y, both export a.
;    ((z (a) ((b y a))    ; import a from y and call it b.
;        (a (lambda (b) (comment body of a in z)))
;        (c (lambda (a) (comment body of c in z)))) ; may use b.
;     (y (a) ((b y a))
;        (a (lambda (x) (comment body of a in y))))); may use b.
;    ((a z a) (b y a))   ; modules body imports.
;    (comment body of modules)) ; this can use a and b.
;
;  ==>
;
(labels
((z::a (labels
((b (lambda (x) (y::a x)))
(c (lambda (a) (z::c a)))
(a (lambda (b)
(comment body of b in z))))
a))
(z::c (labels
((b (lambda (x) (y::a x)))
(a (lambda (b) (z::a b)))
(c (lambda (a)
(comment body of c in z))))
c))
(y::a (labels
((b (lambda (b) (z::a b)))  ; z::c excluded because
(a (lambda (x)             ; it was not exported.
(comment body of a in y))))
a)))
(let ((a z::a)
(b y::a))
(comment body of modules)))
John
```