aboutsummaryrefslogtreecommitdiff
path: root/language/functions.rst
blob: 22a61a387a54570f145175f3da35f06b718d37c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Functions
---------

.. crowbar:element:: 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.

.. crowbar:element:: 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 :crowbar:ref:`include <IncludeStatement>`\ d, 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 :crowbar:ref:`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.

.. crowbar:element:: 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.