► |  | Reference: Racket

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

▼ | 6 | Units

6.1 | Creating Units
6.2 | Invoking Units
6.3 | Linking Units and Creating Compound Units
6.4 | Inferred Linking
6.5 | Generating A Unit from Context
6.6 | Structural Matching
6.7 | Extending the Syntax of Signatures
6.8 | Unit Utilities
6.9 | Unit Contracts
6.10 | Single-Unit Modules
6.11 | Single-Signature Modules
6.12 | Transformer Helpers

On this page:

unit-from-context
define-unit-from-context

top ← prev up next →

#### 6.5`` Generating A Unit from Context

( unit-from-context tagged-sig-spec)

Creates a unit that implements an interface using bindings in the enclosing environment. The generated unit is essentially the same as

( unit
( import )
( export tagged-sig-spec)
( define id expr) ... )

for each id that must be defined to satisfy the exports, and each corresponding expr produces the value of id in the environment of the unit-from-context expression. (The unit cannot be written as above, however, since each id definition within the unit shadows the binding outside the unit form.)

See unit for the grammar of tagged-sig-spec.

( define-unit-from-context id tagged-sig-spec)

Like unit-from-context, in that a unit is constructed from the enclosing environment, and like define-unit, in that id is bound to static information to be used later with inference.
top ← prev up next →