Guide: PLT Scheme

1`` | Welcome to PLT Scheme
2`` | Scheme Essentials
3`` | Built-In Datatypes
4`` | Expressions and Definitions
5`` | Programmer-Defined Datatypes
6`` | Modules
7`` | Contracts
8`` | Input and Output
9`` | Regular Expressions
10`` | Exceptions and Control
11`` | Iterations and Comprehensions
12`` | Pattern Matching
13`` | Classes and Objects
14`` | Units (Components)
15`` | Reflection and Dynamic Evaluation
16`` | Macros
17`` | Performance
18`` | Running and Creating Executables
19`` | Compilation and Configuration
20`` | More Libraries
| Bibliography
| Index

Version: 4.0.2
contents index
← prev up next →

#### 16.2`` General Macro Transformers

The define-syntax form creates a transformer binding for an identifier, which is a binding that can be used at compile time while expanding expressions to be evaluated at run time. The compile-time value associated with a transformer binding can be anything; if it is a procedure of one argument, then the binding is used as a macro, and the procedure is the macro transformer.

The syntax-rules and syntax-id-rules forms are macros that expand to procedure forms. For example, if you evaluate a syntax-rules form directly (instead of placing on the right-hand of a define-syntax form), the result is a procedure:

> (syntax-rules () [(nothing) something])
#<procedure>

Instead of using syntax-rules, you can write your own macro transformer procedure directly using lambda. The argument to the procedure is a values that represents the source form, and the result of the procedure must be a value that represents the replacement form.

16.2.1 Syntax Objects
16.2.2 Mixing Patterns and Expressions: syntax-case
16.2.3 with-syntax and generate-temporaries
16.2.4 Compile and Run-Time Phases
16.2.5 Syntax Certificates

contents index
← prev up next →