creates a function


[ "(" {IC} [ $PARAMETER {{IC} "," {IC} $PARAMETER} {IC} ] ")" {IC} ] [FUNCTION_MODIFIER_0 {IC}] $BLOCK


(a, b) pure { return a * b; }


<int → int> factorial := (x) { return x == 0 ? 1 : x * factorial(x - 1); };


<Collection<T> → T> head := (a&b) { return a; }



Function objects are invoked using the invocation syntax. The FUNCTION_MODIFIER_* rules model: ["stable" | "unstable"] ["throwing" | "throwing []" | "throwing [type0, type1]"] ["atomic"] {PLATFORM} ["pure"|"imperative"|"opaque"] with the caveat that there has to be an IC between any modifier and the next (if there is a next) The atomic, pure, imperative, and opaque keywords influence assumptions that the compiler may make regarding a functions implementation. The pure keyword indicates that the implementation uses only pull semantics, is idempotent, and has no side effects. Additionally, only constants can be read, which includes value (not by reference/pointer values) passed as formal parameters. Any violation of these constraints causes an error to occur. The imperative keyword indicates that the implementation is likely not tractable, and it may interact with memory or hardware in unknown ways. Without either pure or imperative, the implementation is assumed to be push-pull and tractable. If the tool chain determines that this is not the case, it will fall back to imperative behavior. Pure functions are implicitly atomic.

This website does not use cookies or javascript, excluding the Google search bar.
copyright © Brent Lewis 2013-2017