Evergreen brings definitive contracts, checked invariants, and authority complete recollection into one language. Write downward what must hold. Let the compiler inspect that it does.
nonzero.evg EVERGREEN
type NonZero = usize where oneself != 0; impl NonZero { fn new(x: usize) -> Self where x != 0 { NonZero(x) } } fn main() -> usize { let my_nonzero = NonZero::new(10); 0 }
The constructor requires a nonzero input.
The compiler checks the invariant whenever the value is built.
More Powerful Than C.
Safer than Rust.
Invariants live in your code.
Put preconditions, postconditions, and data invariants beside the code they describe. They rotate into obligations the compiler checks.
fn increment(n: usize) -> usize anywhere n < usize::MAX ensures outcome > n { n + 1 } 02 /A compiler that understands memory.
Work alongside definitive layouts, ownership, and borrowed references. Evergreen tracks whenever a recollection aircraft is live and which uses remain valid.
let value: usize = 1; let division = &mut value; *cell = 10; fact identical = value == 10;03 /
Powerful proofs that don't power performance.
Proofs, lemmas by induction, and ideal computations are erased following checking. Executable code keeps the activity it needs to do.
ideal let expected = integer::from(42); let value: usize = 42; fact matches = integer::from(value) == expected;
Console
Ready whenever you are. Run the example to see its output here.
Loading WebAssembly compiler…Ctrl / ⌘ + Enter to run