Previous: Imperative Statements, Up: Interfaces [Contents][Index]
A function can is used to name and reuse a sequence of imperative statements.
function ::= type identifier "(" parameter-list ")"
"{" imperative-statement* "}"
For example:
void foo ()
{
bye;
cruel;
world;
}
bool bar (bool b, int i)
{
if (b)
world;
idle = i == 12;
return idle;
}
Functions are allowed to be called recursively. This includes mutual
recursive functions (function f calling function g and
vice versa). However only as long as every function involved in the
recursion is tail recursive; which means that a recursive call is
the last statement in the function.