4.5. Functions

FunctionDeclaration <- FunctionSignature ';'

Compile-time Behavior:

Provides a declaration of a function with the name, return type, and arguments specified by the signature, but does not specify any behavior. This is generally used as part of an API boundary.

Runtime Behavior:

A function declaration has no runtime behavior.

FunctionDefinition <- FunctionSignature Block

Compile-time Behavior:

Provides the actual behavior of a function, which may have been declared previously or may not. If the function was declared in some .hro file which was included, the function must be exported and available for external use in the compiler’s output. Otherwise, the function should not be exported.

If the function signature specifies a return type other than void, but there are paths through the block that do not execute a ReturnStatement, the compiler must give an error.

Runtime Behavior:

When the function is called, the arguments must be populated and the block must be executed.

FunctionSignature <- Type identifier '(' SignatureArguments? ')'
SignatureArguments <- Type identifier (',' Type identifier)* ','?

Compile-time Behavior:

A function signature specifies the return type, name, and arguments of a function.

Runtime Behavior:

A function signature has no runtime behavior.