Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Examples

Complete programs, not fragments. Each one lives in examples/ with a recorded output in tests/golden/, which enrolls it in the example gate: every CI run compiles it on both backends and diffs what it prints. A program listed here works, or the build is red.

ProgramWhat it exercises
grep_clone.rkCLI flags, file reads, catch on the error branch, string scanning
file_copy.rkError enums with message(), optionals, own at a call site
game_loop.rkFrame update, traits, worker threads. Read it for the loop, not the storage (see below)
text_editor.rkUndo stack, ensure cleanup, linear resources. Same storage caveat
parameter_modes.rkBorrow, mutate, take. The subject of Passing Values

Run one:

rask run examples/grep_clone.rk -- -n pattern file.txt

Two of these store their entities in a Pool with Handles, which racks and links have replaced. That’s sequencing rather than neglect: migrating the examples is step 5 of #908, and it waits on an answer for serialization: a handle is an integer that survives a round trip, and a link is an address, so there’s no link analogue yet. Copy the loop and the undo stack from these; take the storage pattern from racks.md.

There were walkthrough chapters here. They quoted code by hand, were checked only for parsing, and drifted: the game-loop page taught Pool<T>, which the design replaced with racks and links. Guide chapters now pull their code out of these programs (how this book is built), so a walkthrough can’t say something the program doesn’t do.