-
-
Notifications
You must be signed in to change notification settings - Fork 9
Function Call
Functions are called by saying the name of a function and then the supplied arguments surrounded by parentheses, separated by commas.
someFunction(argument1, argument2, argument3, argumentN)
Which function should be called is determined in two stages.
In the first stage, a strict search is done, which will match any functions with the same name, number of arguments, and argument types. If no matches are found in the first search stage, then the second stage will begin and a looser search is done.
The second looser search will match any functions with the same name, compatible number of arguments, and allowed argument deviations. Allowed argument deviations include: ptr
to pointer types, pointer to bool
decay, compatible floating-point values, compatible integer values, and user-defined implicit conversions.
If no other factor can be used to select which should be used, then the first possible function declared will be selected.
Additional Details:
- Polymorphic functions can match during either stage, after non-polymorphic functions are checked.
- Local function pointers are always preferred over functions.
- Functions that have the same name as a local function pointer are unable to be called while it's still in scope.
- Functions are always preferred over global variable function pointers.
Values that have a corresponding __pass__
function, will be passed through __pass__
before the function receives them.
The resulting value is the value returned by the function. If the function returns void
, then it cannot be used within an expression, but only as a statement.
If the callee returns a value that is ignored and the ignored value has a __defer__
, then the corresponding __defer__
will implicitly be called on the neglected value.
Function calls can be made tentative by adding a ?
after the name of the function.
doSomething?()
Tentative function calls will collapse to void
if the compiler cannot compile them.
The ~>
operator can be used to target a specific version of a function that returns a certain type.
getZeroLike() ~> int