  [Contents] · [Home] · [Mail]

## SALIERI Language - Operators and Expressions

Operators

The SALIERI Language contains a variety of operators which are defined on different object types. In general, there are infix operators (which appear between two expressions, like "+") and prefix operators (which appear in front of expressions, like the unary "-" in negative numbers). Every operator in SALIERI can be also written as an ordinary function, for example "a+b" is equivalent to "_PLUS(a,b)". Many operators are overloaded, i.e., they can be applied to objects of different types.

Here is a list of all the operators available in SALIERI:

Numerical Operators

+ numeric positive sign (unary)
- numeric negative sign (unary)

* multiplication (binary)
/ real division (binary)
div integer division (binary)
mod integer division remainder (binary)
- subtraction (binary)

Equality and Relational Operators

= equality (binary)
!= inequality (binary)

< less than (binary)
<= less or equal (binary)
> greater than (binary)
>= greater or equal (binary)

Logical Operators

not boolean negation (unary)
and boolean conjunction (binary)
or boolean disjunction (binary)

Series Operators

# series length (unary)

Miscellaneous Operators

# segment parts (unary)
@ list element access (binary)

Precedences (or binding strengths) between these operators are as follows:
"@" binds stronger than "#", which in turn binds stronger than unary "+" and "-". Next are "*","/", div and mod which have precedence over binary "+" and "-". Next are the equality and relational operators which bind stronger than not, followed by and which has precedence over or.

Expressions

Expressions are pieces of SALIERI code built from object names, constants, operators and functions. Every valid expression is equivalent to an object and therefore has a uniquely defined type. The most simple expressions are constants and names of objects. Moreover, expressions can be built up from other expressions by applying functions or prefix operators or by linking them with infix operators. Finally expressions can be put into parentheses.

Formally, expressions are built according to the following rules:

- object names and constants are expressions;

- if expr is an expression, then (expr) is also an expression;

- if expr is an expression and op a prefix operator, then op expr is an expression;

- if expr_1 and expr_2 are expressions and op is an infix operator, then expr_1 op expr_2 is an expression;

- if fn is an n-place function returning a result value and expr_1, ..., expr_n are expressions then fn(expr_1, ..., expr_n) is an expression.

For an expression to be valid, the arguments of operators and functions have to match the types on which these are defined, otherwise type mismatch errors will occur. Furtheron, for certain operators or functions the values of their arguments are restricted, if these restrictions are violated, specific error conditions will occur (like "division by zero").

Examples:
1+3*5-65 is an integer expression which evaluates to -49;
3.34+a/2 is a real expression, if a is the name of an object with type integer or real;
a!=b and not #b>2 is a boolean expression equivalent to (a != b) and not (#b > 2);
"fe"+retro("abcd") is a string expression which evaluates to "fedcba";
apply(FUNC(2,`return(\$1+\$2+\$1)'), [c1/2], [_/4]) is a sequence expression equivalent to [c1/2 _/4 c1/2];
l(i,#l-i+1) is a list expression, if l is a list object and i an integer object or expression.

[Contents] · [Home] · [Mail]
© sic!systems, page frame designed by hh; this page has been automatically generated from the SALIERI Documentation Database.