8.12. Function declaration

Synopsis: data_type function_name ( [ typed_parameters ] );

A function declaration allows you to declare only a header of a function without its body. It's main purpose is for indirect recursion etc. You have to provide a function definition with exactly the same arguments later in the same file. A new function will be declared in the current namespace named function_name with a parameter list typed_parameters.

Example 8.20. Function declaration

{
    // declares the function - it is defined later
    void nothing();

    integer half( integer value )
    {
	return value / 2;
    }

    // This renders: ...nothing: nil  -  half: 21...
    // uses the function nothing
    y2milestone("nothing: %1  -  half: %2", nothing(), half(42) );

    // defines the function
    void nothing()
    {
	y2milestone("doing nothing, returning nothing");
    }
}