In its simplest form, a module definition looks like this:
(define-structure simple.test (export foo bar) (open rep ;; Make it rule to open `rep' always. rep.structures) (define (foo x) (* x 42)) (define (bar x) (baz x (foo x)) (define (baz x y) (+ (foo x) (1+ y))) (format standard-error "Module %s defined!" (current-structure)) )
This module has the name
simple.test. Then it “exports” two
bar, functions in this case. It also
declare to use modules
entire order is fixed; first
open, and the
Always make it rule to open
rep structure. It’s because Librep
used to offer alternative Lisps, for example Scheme mimicry by
scheme structure, instead of
Then comes the body. They’re evaluated when
evaluated, inside of this module. It defines three functions,
and it emits a message to stderr. The third function
not exported, so it can’t be seen outside of this module.
current-structure is defined in
rep.structures, and it can be used in this module because
rep.structures was opened.
Suppose a module declares to
open a non-existing module. It
signals an error at evaluation as it should be. But byte-compilation
can be done, without any error or messeage. Sorry.
A module can
export a symbol which is not bound in that module.