Arithmetic Expression

The type of an arithmetic operator is the type of the expression that contains it. Operands are automatically coerced to the type of the operator.

In this example the variables are named for their type. The type of the the assignment variable (a cell) determines the type of expression operations on the right hand side. The Byte and Double values are implicitly coerced to a Cell. In this case the Byte value is sign extended to a Cell.


In languages in which operators derive their type from their operands, a set of rules is needed to determine what to do when operand types do not match. In Gilda there is no ambiguity and no such rules are required. As you read an expression it is easy to figure out type coercions. In practice it also turns out that fewer explicit type casts are needed.

Expressions may be nested within matched pairs of parenthesis; which can be "()", "[]" or "{}" characters; your choice. The only String operator is concatenation for which an exclamation point ("!") is used. Real arithmetic operations are always signed.


Since integer variables can be treated as either signed or unsigned, operators for unsigned multiplication and division are provided:


Overall this is easier to work with than having signed and unsigned integer type declarations. You can tell if an operation is unsigned without referencing the type declaration.

The exponentiation operator (^) is unsigned for integer arguments and signed for floating point arguments. Note that a signed real base may not have a fractional exponent. In this case the result is complex and a fault exception is raised. Unsigned integer exponentiation is computed in log2 time using the following algorithm:


Arithmetic expressions and conditions are pure in that they have no side effects. They only read memory and can not perform I/O operations or raise managed exceptions. Like anything else they can raise faults such as division by zero. This distinction is discussed further in the section on Exceptions.

Array Variable

Conditional Expression