(* Vec's tryPush and tryAdd: false when the allocator runs out, the array as it was, and the program going on. *) module VecTry; import Arena, Fmt, Rt, Ints := Vec(INT); import SYSTEM; proc main*; var ar: Arena.Arena; v: Ints.Vec; n: INT; p: ^INT; ok: BOOL; begin if not Arena.init(ar, 4096) then Rt.stop("no arena"); end; Ints.init(v, SYSTEM.ADR(ar.base)); n := 0; while Ints.tryPush(v, n) do INC(n); end; p, ok := Ints.tryAdd(v); Fmt.print("{} {} {} {}\n", [Fmt.int(n), Fmt.int(v.len), Fmt.bool(ok), Fmt.bool(p = nil)]); Ints.reset(v); p, ok := Ints.tryAdd(v); p^ := 5; Fmt.print("{} {} {}\n", [Fmt.bool(ok), Fmt.int(v.len), Fmt.int(Ints.all(v)[0])]); end; end VecTry.