diff options
Diffstat (limited to 'language/functions.rst')
-rw-r--r-- | language/functions.rst | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/language/functions.rst b/language/functions.rst index 86d1144..22a61a3 100644 --- a/language/functions.rst +++ b/language/functions.rst @@ -3,18 +3,36 @@ Functions .. crowbar:element:: FunctionDeclaration <- FunctionSignature ';' - A function declaration defines the return type, name, and arguments of a function without specifying its behavior. - It is generally used as part of an API boundary. + 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 - A function definition provides the actual behavior of a function, which may have been declared previously or may not. + 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. - .. todo:: + Runtime Behavior: - define function linkage/exportedness + 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. |