Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/tests/compiler/progs/arena_borrows.osc # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / compiler / progs / arena_borrows.osc` 29 lines ยท 789 bytes Raw Blame History 1 // entry: borrows 2 // OSC-2 arenas: shared and mutable borrows of arena objects inside the block, 3 // passed to & and &mut parameters; all borrows end before the arena dies. 4 // expect-run: borrows 2 -> 24 5 fn sum4(a: &[u32; 4]) -> u32 { 6 return a[0] + a[1] + a[2] + a[3]; 7 } 8 9 fn bump(a: &mut [u32; 4], k: u32) { 10 for i in 0 .. 4 { a[i] = a[i] + k; } 11 } 12 13 fn borrows(k: u32) -> u32 { 14 let mut s: u32 = 0; 15 arena r bound 8 { 16 let a: own [u32; 4] in r = alloc(1); 17 bump(&mut a, k); 18 { 19 let m: &mut [u32; 4] = &mut a; 20 m[0] = m[0] + 5; 21 let t: &[u32; 4] = &m; 22 s = sum4(&t); 23 } 24 let b: own [u32; 4] in r = alloc(0); 25 let rb: &[u32; 4] = &a; 26 s = s + rb[3] - b[0] + 6 - 2; 27 } 28 return s; 29 }