MinitScript
0.9.31 PRE-BETA
|
See this example that shows functions and recursion.
Argument variables, parsed in function declarations are populated in function context with corresponding values.
If a argument(variable) is prefixed with a & operator in the function declaration, the variable will not be copied into the function arguments, but a reference will be created, means if this variable changes within the function it will also change in the parent variable scope. See &$b and &$c.
Be aware that value by copy variables usually require more instantiation time due to the copy that needs to be made of the variable from parent variable scope to function variable scope.
By default, variables are read from current (variable) context. The default context is the global context. Functions and callables have their own contexts. In this case global variables must be accessed by using the "$$." or "$GLOBAL." accessor.
Stacklets are basically functions without a own stack(or scope), that e.g. holds variables. But stacklets are able to read/write variables of root scope or of a defined scope function scope. Stacklets take no argument if used in root scope. It can take a single argument that names the function the stacklet is bound too, to use its scope.
TODO: Example
A special type of functions are callables. Callables are functions that are used to interact between MinitScript scripts.
Despite the fact that a callable function of a script can be called from another script, they have the limitation that they must not contain MinitScript C++ method calls that require a context function.
Context functions are functions that require a special context. You can ignore this fow now. Default MinitScript does not provide script methods by C++ that require a context.