raz / conform / run / StopNil.raz

22 lines · 413 B · raw · history · last change 7e721e08

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. *)
3module StopNil;
4import Out, Rt;
5
6type Cell = record next: ^Cell; v: I64; end;
7
8proc bye;
9begin
10 Out.str("bye\n");
11end;
12
13proc main*;
14var c: Cell;
15begin
16 _ := Rt.atExit(bye);
17 c.v := 1;
18 Out.str("before\n");
19 Out.int(c.next^.v);
20end;
21
22end StopNil.