raz / conform / run / ProcValue.raz

27 lines · 414 B · raw · history · last change b38de572

1(* Used without parentheses in an expression, a procedure is a value;
2 on its own it is a call. *)
3module ProcValue;
4import Out;
5
6proc hello;
7begin
8 Out.str("hello\n");
9end;
10
11proc five(): I64;
12begin
13 return 5;
14end;
15
16proc main*;
17var f: proc; g: proc(): I64;
18begin
19 f := hello;
20 f();
21 hello;
22 g := five;
23 Out.int(g()); Out.ln;
24 if g = five then Out.str("same\n"); end;
25end;
26
27end ProcValue.