1.9. Procedures
Felix allows you to define procedures.
They're like functions, but they can't return values.
On the other hand, procedures may have side effects,
and they may read input from the driver's message
dispatch queue (which you will learn about much later).
Here is an example of a procedure definition
and use:
Start C++ section to tut/examples/tut112.flx[1
/1
]
1: include "std";
2: proc print_newline (a:int)
3: {
4: print a;
5: print "\n";
6: }
7: print_newline 1;
There is a special short cut for calling procedures
with unit argument: if the procedure is called
by its name, the () can be elided:
Start C++ section to tut/examples/tut113.flx[1
/1
]
1: include "std";
2: print 1; endl();
3: print 2; endl;
More precisely, a statement consisting
of an (almost) atomic expression
is taken to be a call to a procedure with
unit argument. Note there is no confusion
with the use of a procedure name as an expression,
that always represents the closure of the procedure
at the point of writing.
1.9.1. Preconditions and Postconditions