On this page:
Macros and Languages in Racket
2-0523.15

Macros and Languages in Racket

Ryan Culpepper <ryanc@racket-lang.org>

    1 Introduction

      1.1 How to Design Macros

      1.2 Designing Your First Macro

      1.3 Expansion Contexts and Expansion Order

      1.4 Proper Lexical Scoping

      1.5 More Implementations of assert

    2 Terms and Shapes

      2.1 Terms

      2.2 Interpretations of Terms

      2.3 Shapes

    3 Basic Shapes

      3.1 The Expr (Expression) Shape

      3.2 The Body Shape

      3.3 Proper Lexical Scoping, Part 2

      3.4 The Id (Identifier) Shape

      3.5 Expressions, Types, and Contracts

      3.6 Uses of Expressions

    4 Compound Shapes

      4.1 List Shapes

      4.2 Ellipses with Simple Shapes

        4.2.1 Recursive Macros

        4.2.2 Recursive Run-time Helper Function

        4.2.3 Recursive Compile-time Helper Function

      4.3 Ellipses with Compound Shapes

    5 Shape Definitions

      5.1 Defining New Shapes

      5.2 Same Structure, Different Interpretation

      5.3 Helper Macros and Simple Expressions

    6 Enumerated Shapes

      6.1 Defining Enumerated Shapes

        6.1.1 Empty Interface Strategy (Redo Case Analysis)

        6.1.2 Common Meaning Interface Strategy

        6.1.3 Macro Behavior Interface Strategy

        6.1.4 Code Generator Interface Strategy

        6.1.5 AST Interface Strategy

      6.2 Designing Enumerated Syntax

    7 Multi-Term Shapes

      7.1 Shapes for Multiple Terms

        7.1.1 Redo Case Analysis

        7.1.2 Code Generator

        7.1.3 AST

      7.2 Optional Shapes

      7.3 Shapes, Types, and Scopes (★)

    8 Recursive Shapes

      8.1 The Datum Shape

      8.2 Datum as a Recursive Shape

      8.3 Quasiquotation

    9 Compile-Time Computation and Information

      9.1 Compile-Time Computation

        9.1.1 Computation, Whenever

        9.1.2 A Macro Front-End

      9.2 The Static Shape

      9.3 Static Information with Multiple Interfaces

      9.4 Two-Pass Expansion

        9.4.1 Forward References

        9.4.2 The Peculiarities of Scoping in Two-Pass Expansion

    10 Unhygienic Macros

      10.1 Clean Unhygienic Macros

      10.2 Unclean Unhygienic Macros

      10.3 Optionally-Hygienic Macros

      10.4 Syntax Parameters

Creative Commons License This work by Ryan Culpepper is licensed under a Attribution-NonCommercial-NoDerivatives 4.0 International License.