Разделитель
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 a loop, or if you handle the return differently.

If you are typing expressions in a program file you do not have to add a semicolon. In this case genius will simply print the return value whenever it executes the expression. This is the same as when typing on the command line. However, do note that if you are defining a function, the body of the function is a single expression. Usually, therefore, if a function body is long, you will need to enclose it in parentheses.

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