# Expressions - Introduction

Using Expressions

An expression is like an algebraic expression in normal life. An expression can generally be used when any numeric or other type of value is expected. Provided the data type yielded by the expression matches the type expected there should be no problem.

For example the Circle shape expects a numeric value for the first ( radius ) parameter. So you can use a literal number, like 20, or you could use some complex expression that yields a number, e.g. "Sin(3 * x) + 45".

Components of Expressions

An expression consists of terms and operators. Each term in the expression can itself be an expression or an atomic term ( one that cannot be broken down further ).

Atomic Terms

An atomic term consists of either a literal value or a datum ( named variable or constant ). A literal value can be a compound value ( structure or array ), in which case each element of the compound can itself be an expression. so everything eventually reduces to atomic terms and operators.

Operators

There is a large set of operators. Most take numeric values as operands, but all data types have some operators.

Each operator has a fixed precedence and order in which they associate. These can be overridden using parentheses. The system is like the old "BODMAS" from school days.

The following is a summary of all the operators :-

Operator Data Types Precedence Associativity Operation
. Structure 1000 Left Field Access
( Function 1000 Left Function Call
{ Structure 1000 Left Structure Modify
[ Array/Text 1000 Left Indexing
+ Numeric 700 Right Unary Plus
- Numeric 700 Right Unary Minus
^ Numeric 640 Right Power
* Numeric 620 Left Multiplication
/ Numeric 620 Left Division
// Numeric 620 Left Integer Division
Mod Numeric 620 Left Modulo