Functions

Defining and invoking functions

A function definition has the following form:
<RETURNTYPE> <FUNCTIONNAME> ( <ARGUMENTLIST?> )
{
  <FUNCTIONBODY>
}
The returntype is either the special placeholder "void", a fundamentaltype or a user defined type. Functionname is a freely chosen identifier for the function. An Argumentlist is optional. Ommitting the argument list specifies that the function takes no arguments.

Examples of legal function definitions are:
float giveme_pi () { return 3.14f; }   // returns pi (very inaccurately)


int add_numbers (int a, int b, int c)  // function that adds 3 numbers
{                                      // and returns the result
  return a + b + c;
}

void noarguments_voidreturn ()         // a void function with no arguments
{
  dosomething();          
}

Recursion

Recursive function invocation is supported by butter. That means the the classic recursive fibonacci program will work as usual.
/* recursive fibonacci function, only good for benchmarks */
int fibo (int a)
{
  if (a <= 1) return 1;
  return fibo (a - 2) + fibo(a - 1);
}