The function data type is one of the most powerful data types in ZPE/YASS. In ZPE/YASS functions are first-class citizens and can be operated on similarly to other data types.
Functions, although a reference type, do not provide any reference functions.
In a strongly typed program, functions are declared with a data type using the fn
keyword.
Prior to version 1.12.11 this was the function
keyword, but to avoid ambiguity this
was changed.
The following is an example of the function data type in action, including using it with TYPO:
$a = function(){ print("Hello world!") } //Using TYPO (version 1.9.7+) declare b as fn = () => { print("Hello world!") }
Variables containing functions are called lambda or anoymous functions. These variables can be 'called' like a standard function:
$printer1 = function(){ print("Function A!") } $printer1() declare printer2 as fn = () => { print("Function B!") } printer2()