Declarations
Constant declarations
The constant name can not contain lowercase letters. Constants can be assigned to any expressions. The value of the constant is computed when the constant is first accessed, but the type of the constant is automatically determined at the compilation stage by the type of the assigned expression. Therefore, despite the fact that the type is not specified when defining a constant, type checking is in effect when a constant is used.
Constants can be defined in two ways.
Specifying an initial value or an expression for each constant.
Using a common expression with IOTA. Sometimes it is necessary to define a list of constants with values that are computed according to certain rules. In this case, after the const keyword, you need to specify one common expression that will be calculated for each constant in this definition. In this expression, you can use the special variable IOTA, which is equal to the ordinal index of the constant in the list, starting at zero. Constants should be separated by a space or a new line.
Function declarations
The function declaration consists of two parts - a description of the parameters with the return type and the function body. When you define a function, you must specify the keyword "func", the function name, the parameters to be passed, and the type of the return value. Only the function name is required.
The final incoming parameter in a function signature may have a '...' suffix. A function with such a parameter is called variadic function and may be invoked with zero or more arguments for that parameter. You get this parameter as an array of arguments. For example, int pars... means that pars is really arr.int and you can get the i-th argument with pars[i].
Run declaration
The Gentee script must contain a special function without parameters, which is defined using the keyword "run". The script starts by calling this function. The script must have only one definition of "run".
Last updated