Cairo Memory Model
- Write-once memory. Cairo memory is immutable: each cell written once, a property the proof system requires.
- Linear types. Values move linearly: used once unless the type says otherwise, ownership Rust-style.
- Why the model exists. The memory model is not style: it is what makes execution provable at all.
References and Snapshots
- Snapshots. A snapshot (@value) is an immutable view: reading without consuming ownership.
- ref arguments. A ref argument lets a function mutate the caller’s variable: rebinding tracked explicitly.
- Desnap. The desnap operator reads through a snapshot: views opened where values are needed.
Designing Safe Data Flow
- Move by default. Values move into calls: the compiler tracks every owner, double-use fails to compile.
- Copy and Drop traits. Copy and Drop derive where duplication and disposal are safe: declared, never assumed.
- Ownership as design. Data flow designs like Rust: one owner, borrows for reading, mutation explicit.
Before and after this level
- Before: Level 2: Data Structures: Structs and Enums, Pattern Matching, Collections.
- Next: Level 4: Traits & Generics: Traits, Generic Types, Reusable Cairo Abstractions.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Cairo Level 3: Ownership & Memory cover?
Cairo Memory Model, References and Snapshots, Designing Safe Data Flow: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 2: Data Structures, which covers Structs and Enums, Pattern Matching, Collections.