Next: , Previous: Language, Up: Language


2.1 Operators

Enigma has 4 operators: !, =, |, and *. ! and = are the most important ones.

To assign values to variables, use the = operator. For example:

obj = hello-string;
Here, the variable hello-string receives the object obj. Note the syntax. The objects comes first. Unless hello-string is already defined, it is created as a local variable.

Now, say we have a function called think and we want to send objects to it. This is how that's done:

obj1 obj2 obj3 ! think;

There are no limits to the amount of objects that can be sent to a function. Whitespace characters are used to separate objects, also when assigning them to a variable. There is a difference between using one object and more objects as arguments, though. When using only one object, that object is simply used, but when using more objects, a list containing all objects is created and transmitted instead. So, in reality, when assigning two or more objects to a variable, the variable points to a list with the objects. More about lists later.

The | operator is merely a shortcut operator. It can merge several commands into one, long command. See the following example:

# Long version
a ! b = c;
d c ! e = c;
# Short version
a ! b | d temp ! e = c;

Here, a is sent to b, which is then — together with d — sent to e and saved in c. The | acts like the semicolon, but it copies the return value of the last function (in this case b) and stores the value in the local variable temp. Hackers are encouraged to use this operator.

The final operator, *, has the same function as =, except that it works on a global level. So, if the code is b = a; and a does not exist, it is created — in the global space.