TYL PROGRAMMING LANGUAGE
▶ TYL FUNCTION STRUCTURE
To learn about functions in Tyl, use functions page. Here is a schematic description of function statements in Tyl.
Terminology
token
valid Tyl variable name
function name
token
parameters list
list of tokens
function symbol
colon character ':', or Tyl function symbol '»'
statement end symbol
caret character '^', or Tyl statement end symbol 'ᐤ'
function signature
statement that is composed of function name, parameters list and function symbol
statement
one or more lines of code, that construct a programming functionality
one line statement
statement that is written in one line of code
function statement
one or more lines of code, that construct a function
Function Signature
There are two types of function signatures: Signature of function without parameters:
[FUNCTION NAME] [FUNCTION SYMBOL]

Signature of function with parameters:
[FUNCTION NAME] [PARAMETERS LIST] [FUNCTION SYMBOL]

The only difference between the two types is that the parameterless function does its activity without need for incoming parameters, so its signature consists only of its name and the function symbol.
If a function has parameters, they will be placed between the name and the function symbol.
Function Statement
There are two types of Tyl function statements: One line function statement structure:
[FUNCTION SIGNATURE] [ONE LINE STATEMENT]

In this type of function statement, the function signature, along with a one line statement, are written in one line. This is good for actions that can be folded into one line.

Multiline function statement structure:
[FUNCTION SIGNATURE]
[STATEMENT]
[STATEMENT]
[STATEMENT]
...

In this type of function statement, the function signature is written in the first line of the function statement, and its statements are written in the next lines.
It is forbidden to write a function statement inside another function statement, but erroneously, it will be regarded as a new function statement.
Also note that if you mix the two types, Tyl will accept it as a multiline function statement by prepending the first one line statement to its statements list.
And finally, a function statement does not need a statement end symbol.

Full function structure:
[FUNCTION SIGNATURE SECTION]
 [FUNCTION NAME] [PARAMETERS LIST] [FUNCTION SYMBOL]

[STATEMENTS LIST SECTION]
 [STATEMENT]
 [STATEMENT]
 [STATEMENT]
 ...
Function Statements in a Module
As described in program structure page, module (program) structure is composed of two optional sections, the second of them is the module functions section. We describe here an optional module structure.

Functional module structure:
[MODULE STATEMENTS SECTION]
 [STATEMENT]
 [STATEMENT]
 ...

[MODULE FUNCTIONS SECTION]
 [FIRST FUNCTION]
 [SECOND FUNCTION]
 [THIRD FUNCTION]
 ...

Module functions structure:
[FIRST FUNCTION SIGNATURE]
[STATEMENTS LIST]

[SECOND FUNCTION SIGNATURE] [ONE LINE STATEMENT]

[THIRD FUNCTION SIGNATURE]
[STATEMENTS LIST]