An expression is a construct that evaluates to a value. Syntactic constructs that are executed to produce a side effect and return no value are called statements (see Statements). Expressions appear as right hand sides of assignments (see Assignments), as actual arguments in function calls (see Function Calls), and in statements.
Note that an expression is not the same as a value. For example
1 + 11
is an expression, whose value is the integer 12. The external
representation of this integer is the character sequence
12, i.e., this
sequence is output if the integer is printed. This sequence is another
expression whose value is the integer 12. The process of finding the
value of an expression is done by the interpreter and is called the
evaluation of the expression.
Variables, function calls, and integer, permutation, string, function, list, and record literals (see Variables, Function Calls, Integers, Permutations, Strings and Characters, Functions, Lists, Records), are the simplest cases of expressions.
Expressions, for example the simple expressions mentioned above, can be
combined with the operators to form more complex expressions. Of course
those expressions can then be combined further with the operators to form
even more complex expressions. The operators fall into three classes.
The comparisons are
Comparisons and In). The arithmetic operators are
^ (see Operations). The logical operators are
or (see Operations for Booleans).
gap> 2 * 2; # a very simple expression with value 4 gap> 2 * 2 + 9 = Fibonacci(7) and Fibonacci(13) in Primes; true # a more complex expression
Previous Up Top Next