The unit form creates a unit:
(unit
(import identifier
where each unit-body-clause is a define clause, a
define-struct clause, or any Scheme expression. The syntax
of define and define-struct clauses is the same as for
define and define-struct expressions. The variables defined
by define and define-struct clauses are
internal variables. Internal variables that are named in the
export clause are exported variables.
)
(export export-identifier
)
unit-body-clause
)
Within a unit body, the names of all built-in MzScheme primitives are bound to their primitive values when the name is otherwise unbound. No other global variables can be referenced or mutated in a unit body. References to built-in MzScheme primitives always return the primitive value, not the value currently bound to the global variable with the same name. For example, car in a unit body always references the built-in primitive car. (Of course, car can be defined within the unit, imported, or bound outside of the unit expression with let or lambda.)
The identifiers in the import clause are bound within the body of the unit. The variables exported by the export clause must be defined in the unit body with define or define-struct. Imported variables cannot be redefined and internal and exported variables can be defined only once. Imported variables cannot be mutated using set! in a unit body, but internal and exported variables can be mutated.
Each export-identifier has one of these forms:
identifier
(internal-identifier external-identifier)
The first form exports the variable defined as identifier in
the unit body using the external name identifier.
The latter exports the variable defined as internal-identifier
using the external name external-identifier. All
external identifiers in a export clause must be unique.