16 Macros
top
up

16MacrosπŸ”— i

A macro is a syntactic form with an associated transformer that expands the original form into existing forms. To put it another way, a macro is an extension to the Racket compiler. Most of the syntactic forms of racket/base and racket are actually macros that expand into a small set of core constructs.

Like many languages, Racket provides pattern-based macros that make simple transformations easy to implement and reliable to use. Racket also supports arbitrary macro transformers that are implemented in Racket—or in a macro-extended variant of Racket.

This chapter provides an introduction to Racket macros, but see Fear of Macros for an introduction from a different perspective.

Racket includes additional support for macro development: A macro debugger to make it easier for experienced programmers to debug their macros and for novices to study their behavior, and of macros. And the syntax/parse library for writing macros and specifying syntax that automatically validates macro uses and reports syntax errors.

top
up

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /