7.7 Extending the Syntax of Signatures

► |  | 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

On this page:

define-signature-form
struct/ ctc

top contents ← prev up next →

### 7.7 Extending the Syntax of Signatures🔗ℹ

> syntax (define-signature-form sig-form-id expr)
> (define-signature-form (sig-form-id id) body ...+)
> (define-signature-form (sig-form-id id intro-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 that accepts one argument. In the second form, sig-form-id is bound to a transformer procedure whose argument is id and whose body is the bodys. The third form is like the second one, but intro-id is bound to a procedure that is analogous to syntax-local-introduce for the signature-form expansion.

The result of the transformer procedure 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.)

Changed in version 8.1.0.7 of package base: Added support for the form with a transformer expr.

> 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 contents ← prev up next →