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.
| Chapter | What it covers |
|---|---|
| Values | The kinds of value, structs, enums, literal unions, nothing implicit |
| Ownership and mutation | Copies and moves, let and var, mut parameters, lends, aliasing and invalidation |
| Domains, ranges and index spaces | Domains, positions and cuts, ranges, and keys that survive slicing |
| Types, widths and proofs | Four number types, range types, storage widths, proofs, Mod<P> |
| Optionals | ?T instead of sentinels: lifted arithmetic, min=, ? and ! |
| Multitest state | The @!multitest divider, per-case scope and early exit |
| Checked operations and build profiles | What is proved, what cpl run traps on, what release does |
| Standard library design | One vocabulary, named options, visible costs, no privilege |
| C++ and the judge model | The one C++ file, judge profiles, and why local runs match the judge |