Memory model
This page is a learning-oriented companion to the canonical memory model: memory model.
At a high level:
- Most values are plain, copyable scalars (or structs that lower to a fixed set of scalar slots in Silk).
- Heap allocation is introduced via
new, producing&Structreferences. withregions can redirectnewallocations away from the heap (see regions).
Notes#
- Canonical spec + implementation notes: memory model
Example: new + reference field access#
struct Point {
x: int,
y: int,
}
fn main () -> int {
let p: &Point = new Point{ x: 1, y: 2 };
return p.x + p.y;
}
See also#
- Regions (
with): regions Dropand cleanup hooks: interfaces
Source repository · Edit this page · View Markdown