Files
Slava Pestov 7338bba303 docs/Generics: Start writing the last two chapters
- property-map.tex is based on some notes I wrote up in 2021
- minimization.tex incorporates material from our rejected PLDI '24 submission

They're still pretty rough and incomplete.

Also, extract some more code examples into separate files for
easier verification, and fix various typos.
2026-11-29 21:29:19 -05:00
..

Compiling Swift Generics

This is a book about the implementation of generic programming--also known as parametric polymorphism--in the Swift compiler. The first four chapters also give an overview of the Swift compiler architecture in general.

Downloading the PDF

A periodically-updated PDF is available here:

https://download.swift.org/docs/assets/generics.pdf

Typesetting the PDF

It's written in TeX, so to typeset the PDF yourself, you need a TeX distribution. Either of the following should work:

Using make

Running make in docs/Generics/ will run pdflatex and bibtex in the right order to generate the final document with bibliography, index, and cross-references:

cd docs/Generics/
make

Using latexmk

A more modern alternative is to use latexmk, which runs pdflatex and bibtex until fixed point:

cd docs/Generics/
latexmk -pdf generics.tex

Manually

You can also just do this:

cd docs/Generics/
pdflatex generics
bibtex generics
pdflatex generics
pdflatex generics

Reading the PDF

The book makes use of internal hyperlinks so it is best to use PDF reader with support for PDF bookmarks and back/forward history. Preview.app on macOS fits the bill; you can add Back/Forward buttons to the toolbar with View > Customize Toolbar. However, the font size and link targets are probably too small for a smartphone display, so I recommend using something bigger.

Current Status

This is a work in progress. The following chapters are unfinished:

  • Part III:
    • The Property Map
    • Minimization

Citing the book

To cite this book with BibTeX, use something like the following, and please ensure the URL is visible in your output:

@misc{csg,
  title  = "Compiling {S}wift {G}enerics",
  author = "Slava Pestov",
  url    = "https://github.com/swiftlang/swift/tree/main/docs/Generics",
  year   = {2026}
}