Enki Language

The Enki language serves to compose expressions and functions in Sfairadora. The objective of its design was to facilitate writing very simple expressions (like (a+b)/2) without any annoying syntactic complication, while not limiting more advance use of the language. The advanced constructs include error handling, compound values, for cycle provisions for easy searching and value aggregation etc.
As it is usual with modern programming languages, Enki has free syntax. That means that identifiers, keywords, and operator are separated with a white-space, where the term white-space means an arbitrary sequence of spaces, tabulator and new-lines. At the place of a white-space, also a comment can be used. If an identifier precedes or follows an operator composed of a non-alphanumeric characters (e.g. ‘+’, ‘=’, ‘!’, etc), it needs not to be separated with a space (for instance, instead of x + y, it can be just written x+y, omitting spaces).
On contrary to other programming languages, Enki permits using characters with diacritical signs in identifiers. This allows non-English speakers to use native language words as identifiers in their proper form.
The Enki language is, in its structure, based on the languages like C, Java, PHP, and similar, nonetheless, it relaxes some of their limitation. Most important, there is no difference between a command, which does not return a value, and an expression, which does – in Enki, all the language constructs return a value. Therefore, a function (program) is in principle composed by a single expression. Certain consequences follow from this design. Firstly, there is no distinction between parentheses and curly brackets, as parentheses are, too, used to group portions of code corresponding to blocks in languages like C. (The curly brackets are used to write compound values.) For instance:
a = 1;
b = 1
x = 0;
Next, as apparent from the example above, a semicolon does not terminate a command (as there is no such concept as command in Enki), but rather it joins two expressions so that the result of the compound expression is the result of the second expression. (Therefore, a semicolon has an analogical function to the comma operator in the C language). A consequence for syntax follows that it is not necessary to write a semicolon at the end of the last expression (although it is permitted to write it there, but it has no function). Nonetheless, it must not be used at certain places, like in front of else, because such a usage would terminate the if statement and the else keyword would stay solitary.
The fact that all constructs return a value has the advantage that expressions like the following can be written:
x = if(y>0) a/y else 0
The result of the if operator is the result of the evaluated branch. Hence, in the example above, the quotient a/y will be assigned to x if y is greater than zero. In other cases, zero is assigned.
Before studying this chapter, it is recommended to become familiar with Sfairadora data model and especially with the concept of data type.

Practical Notes

For practical using the Enki language, the Insert menu is very useful, as it contains the list of all Enki language constructs, functions, operators, and all data items available from the function being edited. The list is present in menu whenever an Enki expression is edited.
For testing Enki language examples, the field for quick evaluation of expressions located in the Definitions document section, subsection Funkce. Another way is to create a computed item in the document section View. This is suitable when the expression has no side effects, and it returns a scalar value (a non-scalar value can be typecast to a String). If a function manipulates with document data or with a presentation, a better approach is to create a button in the section Presentation and set its action to Enki expression evaluation.