12.13 Phase and Space Utilities

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

▼ | 12 | Macros

12.1 | Pattern-Based Syntax Matching
12.2 | Syntax Object Content
12.3 | Syntax Object Bindings
12.4 | Syntax Transformers
12.5 | Syntax Parameters
12.6 | Local Binding with Splicing Body
12.7 | Syntax Object Properties
12.8 | Syntax Taints
12.9 | Expanding Top-Level Forms
12.10 | Serializing Syntax
12.11 | File Inclusion
12.12 | Syntax Utilities
12.13 | Phase and Space Utilities

On this page:

phase?
space?
phase+ space?
phase+ space
phase+ space-phase
phase+ space-space
phase+ space-shift?
phase+ space+
phase+ space-shift+

top contents ← prev up next →

#### 12.13`` Phase and Space Utilities🔗ℹ

(require racket/phase+space) | package: base

The bindings documented in this section are provided by the racket/phase+space library, not racket/base or racket.

The racket/phase+space library provides functions for manipulating combined representations of phase levels and binding spaces, particularly as used for require transformers and provide transformers.

When identifier-binding (and related functions, like identifier-transformer-binding), syntax-local-module-exports, syntax-local-module-required-identifiers, module-compiled-exports, or module->exports produces a phase–space combination (or phase–space shift combination), then two such values that are equal? will be eqv?.

Added in version 8.2.0.3 of package base.

> procedure (phase? v) → boolean?
> v : any/c

Returns #t if v is a valid representation of a phase level, #f otherwise. A valid representation is either an exact integer representing a numbered phase level or #f representing the label phase level.

> procedure (space? v) → boolean?
> v : any/c

Returns #t if v is a valid representation of a binding space, #f otherwise. A valid representation is either an interned symbol representing the space whose scope is accessed via make-interned-syntax-introducer, or #f representing the default binding space.

> procedure (phase+space? v) → boolean?
> v : any/c

Returns #t if v is a valid representation of a phase level and binding space combination, #f otherwise. The possible representations are as follows:

- a phase (in the sense of phase?) by itself, which represents that phase plus the default binding space

- a pair whose car is a phase and whose cdr is a non-#f space (in the sense of space?)

> procedure (phase+space phase space) → phase+space?
> phase : phase?
> space : space?

Returns a value to represent the combination of phase and space.

> procedure (phase+space-phase p+s) → phase?
> p+s : phase+space?
> procedure (phase+space-space p+s) → phase?
> p+s : phase+space?

Extracts the phase level or binding space component from a combination.

> procedure (phase+space-shift? v) → boolean?
> v : any/c

Returns #t if v is a valid representation of a phase level shift and binding space shift combination, #f otherwise. A shift can be applied to a combination of a phase level and binding space using phase+shift+. The possible representations of a shift are as follows:

- exact integer — represents an amount to shift a phase level and no change to the binding space

- #f — represents a shift to the label phase level and no change to the binding space

- a pair whose car is an exact integer or #f, and whose cdr is a space (in the sense of space?) — represents a phase level shift in the car and a change to the binding space that is in the cdr

> procedure (phase+space+ p+s shift) → phase+space?
> p+s : phase+space?
> shift : phase+space-shift?

Applies shift to p+s to produce a new combination of phase level and binding space.

> procedure (phase+space-shift+ shift additional-shift) → phase+space-shift?
> shift : phase+space?
> additional-shift : phase+space-shift?

Composes shift and additional-shift to produce a new shift that behaves the same as applying shift followed by additional-shift.
top contents ← prev up next →