7.10 Single-Unit Modules

► |  | The Racket Reference

1 | Language Model
2 | Notation for Documentation
3 | Syntactic Forms
4 | Datatypes
5 | Structures
6 | Classes and Objects
7 | Units
8 | Contracts
9 | Pattern Matching
10 | Control Flow
11 | Concurrency and Parallelism
12 | Macros
13 | Input and Output
14 | Reflection and Security
15 | Operating System
16 | Memory Management
17 | Unsafe Operations
18 | Running Racket
| Bibliography
| Index

▼ | 7 | Units

7.1 | Creating Units
7.2 | Invoking Units
7.3 | Linking Units and Creating Compound Units
7.4 | Inferred Linking
7.5 | Generating A Unit from Context
7.6 | Structural Matching
7.7 | Extending the Syntax of Signatures
7.8 | Unit Utilities
7.9 | Unit Contracts
7.10 | Single-Unit Modules
7.11 | Single-Signature Modules
7.12 | Transformer Helpers

Racket
top contents ← prev up next →

### 7.10 Single-Unit Modules🔗ℹ

As a language name with #lang, racket/unit provides all bindings of racket/unit and racket/base except for %#module-begin, and the racket/unit module body is treated as a unit body. The body must match the following module-body grammar:

module-body |  | = |  |
require-decl ...
(import tagged-sig-expr ...)
(export tagged-sig-expr ...)
init-depends-decl
unit-body-expr-or-defn
...
require-decl |  | = |  | (require require-spec ...)
|  | | |  | (begin require-decl ...)
|  | | |  | derived-require-form

After any number of require-decls, the content of the module is the same as a unit body with access to racket/base.

The resulting unit is exported as base@, where base is derived from the enclosing module’s name (i.e., its symbolic name, or its path without the directory and file suffix). If the module name ends in -unit, then base corresponds to the module name before -unit. Otherwise, the module name serves as base.

top contents ← prev up next →