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
omega-mv / seed / omc / tests / struct-bool / param_edit.om
| 1 | note param_edit.om: a bool field written and read through an edit parameter, and a bool value |
| 2 | note passed as a parameter. set true, flip, set false; the caller sees every change. Result 7. |
| 3 | struct W a uint f bool end |
| 4 | fn setf p edit W v bool to void |
| 5 | put p f v |
| 6 | end |
| 7 | fn flip p edit W to void |
| 8 | if eq get p f true |
| 9 | put p f false |
| 10 | else |
| 11 | put p f true |
| 12 | end |
| 13 | end |
| 14 | fn main to uint |
| 15 | w = new W 3 false |
| 16 | r = uint 0 |
| 17 | setf w true |
| 18 | if eq get w f true |
| 19 | r = add r 1 |
| 20 | end |
| 21 | flip w |
| 22 | if eq get w f false |
| 23 | r = add r 2 |
| 24 | end |
| 25 | flip w |
| 26 | if eq get w f true |
| 27 | r = add r 4 |
| 28 | end |
| 29 | ret add r sub get w a 3 |
| 30 | end |