From 015d0afcdc0e247e4d9ac01f3a05be58168d048d Mon Sep 17 00:00:00 2001
From: James Clark
A function is a part of a program that can be explicitly executed. In Ballerina,
@@ -1753,14 +1752,7 @@ Functions
function-type-descriptor :=
function
function-signature
function-signature := (
param-list )
return-type-descriptor
-return-type-descriptor := [ returns
[annots] type-descriptor ]
Functions
passed to or returned from functions. When a function is executed, it is passed
an argument list as input and returns a value as output.
-When the execution of a function returns to its caller, it returns exactly one
-value. A function that would in other programming languages not return a value
-is represented in Ballerina by a function returning ()
. Note that
-the function definition does not have to explicitly return ()
; a
-return statement or falling off the end of the function body will implicitly
-return ()
.
-
param-list := required-params [,
defaultable-params] [,
rest-param] @@ -1847,6 +1839,22 @@Functions
make use of arguments specified both by position and by name, is described in more detail in the section on function calls. +return-type-descriptor := [+returns
[annots] type-descriptor ] ++When the execution of a function returns to its caller, it returns exactly one +value. A function that would in other programming languages not return a value +is represented in Ballerina by a function returning
+()
. Note that +the function definition does not have to explicitly return()
; a +return statement or falling off the end of the function body will implicitly +return()
. ++The value returned by a function will belong to the type specified in the +return-type-descriptor. An empty return-type-descriptor is equivalent to +
returns ()
. +Function types are covariant in their return types and contravariant in the type of their parameter lists. More precisely, a function type with return type R and