raz / conform / run / StopNilProc.raz

20 lines · 357 B · raw · history · last change 7e721e08

1(* Calling a nil procedure 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 StopNilProc;
4import Out, Rt;
5
6
7proc bye;
8begin
9 Out.str("bye\n");
10end;
11
12proc main*;
13var p: proc;
14begin
15 _ := Rt.atExit(bye);
16 Out.str("before\n");
17 p();
18end;
19
20end StopNilProc.