Skip to Content
Language in depth

Overview

One chapter per part of CP Lang: the rules, examples that run, and why each part is designed the way it is.

The course teaches CP Lang by solving problems. These chapters are for readers who want the whole model behind it: what each rule says, the smallest program that shows it, and why the language chose it over the alternatives.

Each chapter:

  • states the rules and links each one to the normative text in the language reference, which wins wherever the two differ;
  • shows every rule in code you can run and edit in place, including the mistakes it stops, with the compiler's error;
  • ends with Why it's designed this way, citing the entries of the design decisions that made each call and the alternatives they rejected.
ChapterWhat it covers
ValuesThe kinds of value, structs, enums, literal unions, nothing implicit
Ownership and mutationCopies and moves, let and var, mut parameters, lends, aliasing and invalidation
Domains, ranges and index spacesDomains, positions and cuts, ranges, and keys that survive slicing
Types, widths and proofsFour number types, range types, storage widths, proofs, Mod<P>
Optionals?T instead of sentinels: lifted arithmetic, min=, ? and !
Multitest stateThe @!multitest divider, per-case scope and early exit
Checked operations and build profilesWhat is proved, what cpl run traps on, what release does
Standard library designOne vocabulary, named options, visible costs, no privilege
C++ and the judge modelThe one C++ file, judge profiles, and why local runs match the judge