| 1 | (* Used without parentheses in an expression, a procedure is a value; |
| 2 | on its own it is a call. *) |
| 3 | module ProcValue; |
| 4 | import Out; |
| 5 | |
| 6 | proc hello; |
| 7 | begin |
| 8 | Out.str("hello\n"); |
| 9 | end; |
| 10 | |
| 11 | proc five(): I64; |
| 12 | begin |
| 13 | return 5; |
| 14 | end; |
| 15 | |
| 16 | proc main*; |
| 17 | var f: proc; g: proc(): I64; |
| 18 | begin |
| 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; |
| 25 | end; |
| 26 | |
| 27 | end ProcValue. |