| 1 | (* Following nil stops the program. The program ends with status 2, after the procedures registered |
| 2 | with Rt.atExit, so that what it wrote is out. *) |
| 3 | module StopNil; |
| 4 | import Out, Rt; |
| 5 | |
| 6 | type Cell = record next: ^Cell; v: I64; end; |
| 7 | |
| 8 | proc bye; |
| 9 | begin |
| 10 | Out.str("bye\n"); |
| 11 | end; |
| 12 | |
| 13 | proc main*; |
| 14 | var c: Cell; |
| 15 | begin |
| 16 | _ := Rt.atExit(bye); |
| 17 | c.v := 1; |
| 18 | Out.str("before\n"); |
| 19 | Out.int(c.next^.v); |
| 20 | end; |
| 21 | |
| 22 | end StopNil. |