Iron Realms Entertainment
Expressions are the building blocks of complex behavior in any programming language. They are what allow you to combine simple terms to perform meaningful operations, and eventually output a single ‘value’.
Each expression is composed of one or more terms, perhaps joined together by operators or procedure calls. Almost any place that calls for a value, you can use an expression to supply that value. Combine constants, variables, function calls, database lookups, search results, anything. As long as the types are consistent (or compatible) you’ve got a valid expression.
Comparisons do just that, compare. For integers, this is a numerical comparison, and for strings, this is an alphabetical comparison (as in an alphabetization (A-Z) of ascii values). Comparison operations return a boolean value (0 for false, 1 for true) in an integer.
Logical operators perform boolean logic on the values. They take boolean values on each side (or if normal values are used, the following rules are used to evaluate the truth value of a term: 1) if it’s an integer, non-zero is true, 0 is false, 2) if it’s a string, a length greater than 0 is true, otherwise false, 3) if it’s a vector, a size greater than 0 is true, otherwise false).
or Logical OR
Assignment operators are used to put a value into something, be it a variable or database. The assignment operator is the ‘=’ character. However, it can be combined with various other operators to provide a shortcut in writing an assignment. For example: ‘+’ can be combined with ‘=’ to form ‘+=’. When using an operator in this way, the assignment “x += 5” is treated like “x = x + 5” for all practical purposes.
The operators ‘++’ and ‘--’ can be used to add or substract a 1. Using ‘a++’ is identical to ‘a += 1’, and ‘a--’ corresponds to ‘a -= 1’.
Precedence determines the order of evaluation for all operators. Lower precedence operations are performed after higher precedence ones. The following listing provides a listing of the precedence for all operators in increasing precedence.