► |  | The Racket Reference

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 and Parallelism
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:

define-signature-form
struct/ ctc

top← prev up next →

#### 6.7`` Extending the Syntax of Signatures

> > syntax

> > (define-signature-form sig-form-id expr)

> (define-signature-form (sig-form-id id) body ...+)

Binds sig-form-id for use within a define-signature form.

In the first form, the result of expr must be a transformer procedure. In the second form, sig-form-id is bound to a transformer procedure whose argument is id and whose body is the bodys. The result of the transformer must be a list of syntax objects, which are substituted for a use of sig-form-id in a define-signature expansion. (The result is a list so that the transformer can produce multiple declarations; define-signature has no splicing begin form.)

> > syntax

> > (struct/ctc id ([field contract-expr] ...) struct-option ...)

> field |  | = |  | id
> |  | | |  | [id #:mutable]
> struct-option |  | = |  | #:mutable
> |  | | |  | #:omit-constructor
> |  | | |  | #:omit-define-syntaxes
> |  | | |  | #:omit-define-values

For use with define-signature. The struct/ctc form works similarly to struct, but the constructor, predicate, field accessors, and field mutators are contracted appropriately.
top← prev up next →