Facts on results
A result carries what is true of it.
sort makes xs sorted(byAge). binarySearch needs that fact, and the compiler checks it before anything runs. Every other line keeps it, turns it, or drops it.
ages.vyrnproved
let xs = readAges()
.sort(byAge)
.reverse()
.filter(isAdult)
.map(jitter)
xs.push(17)
binarySearch(xs, 30) // needs sorted(byAge)
// click a line to add or remove it
Effects
Every function says what it touches.
A pure function keeps everything inside the seal. print leaps over it to stdout; a write to count runs out to its buoy. A gen fn must stay sealed.
table.vyrnpure
gen fn table() -> Array<Int64> {
let xs = build()
print(xs.length)
count = count + 1
return xs
}
// click gen, print or count
No collector
Every value sinks once, at a point known before the run.
Nothing piles up and nothing is swept. Press run and watch the pool drain: allocations equal frees.
main.vyrnready
fn main() {
let xs = readAges() // owned by xs
let s = summarize(xs) // xs moves in
print(s) // released at its end
}
90,000allocated0released
Still water
Write the rule. Let the compiler carry it.
Install Vyrn