Разделитель
Prev | Chapter 5. Основы GEL | Next

## Разделитель

GEL is somewhat different from other languages in how it deals with multiple commands and functions. In GEL you must chain commands together with a separator operator. That is, if you want to type more than one expression you have to use the `;` operator in between the expressions. This is a way in which both expressions are evaluated and the result of the second one (or the last one if there is more than two expressions) is returned. Suppose you type the following:

    3 ; 5

This expression will yield 5.

This will require some parenthesizing to make it unambiguous sometimes, especially if the `;` is not the top most primitive. This slightly differs from other programming languages where the `;` is a terminator of statements, whereas in GEL it’s actually a binary operator. If you are familiar with pascal this should be second nature. However genius can let you pretend it is a terminator to some degree. If a `;` is found at the end of a parenthesis or a block, genius will append a null to it as if you would have written `;null`. This is useful in case you do not want to return a value from say a loop, or if you handle the return differently. Note that it will slightly slow down the code if it is executed too often as there is one more operator involved.

If you are typing expressions in a program you do not have to add a semicolon. In this case genius will simply print the return value whenever it executes the expression. However, do note that if you are defining a function, the body of the function is a single expression.

Prev | Up | Next
Использование функций | Home | Comments