diff options
author | Melody Horn <melody@boringcactus.com> | 2020-11-02 13:37:32 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2020-11-02 13:37:32 -0700 |
commit | 8868b5fa2e8b9f40a31035c51519cce40e73f079 (patch) | |
tree | 4a91e7d5437f91a7f95358753097a99e2c84cf2e /language/functions.rst | |
parent | 83e23b6b449112f4a85d09c57e5601faa87856ca (diff) | |
download | spec-8868b5fa2e8b9f40a31035c51519cce40e73f079.tar.gz spec-8868b5fa2e8b9f40a31035c51519cce40e73f079.zip |
define compile-time vs runtime behavior
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. |