Values can be assigned in an assignment statement or in a declaration.
The Assignment Statement (:=)
Values are assigned to variables with the assignment statement (:=). Unlike some languages, assignment is not an operator: it cannot be used in an expression.
=> x := 5 * ( 7 + 2 );
Assignments and Limited Types
Some built-in types are "limited". This means they cannot be assigned using the assignment statement.
Boolean True Shortcut
As a special exception, stating a boolean's name implies that the boolean is assigned true. This only applies to boolean or subtypes of boolean. The shortcut only assigns true (not false). It can only be used with scalar variables (not arrays or records)
done : boolean := false;
Under pragma ada_95, the boolean true shortcut is not allowed.
AdaScript expressions can contain the following operators:
The bitwise operators are identical to the boolean operators: SparForte choses which to use on the context of the expression.
in and not in test for membership in a range. (In Ada, the range can be a type but under AdaScript types have no bounds.) The range can be an pair of numbers, characters (not strings) or a pair of enumerated items.
=> b := green in red..blue;
in and not in are technically not operators.
Ada: and then and or else not yet implemented. Character ranges not yet implemented.
Expressions and Order of Operations
An expression is a combination of operands and operators used to compute a result value.
Expression operators are evaluated in the following order:
Subexpressions can be created using parantheses.
If pragma ada_95 is used, expression parantheses are required in certain cases.
Ada: SparForte has looser restrictions on parantheses unless pragma ada_95 is used.
|Back To Top|