Chapter 3 The Application Description Language
3.7 Expressions
You construct expressions from variables (see Section 3.6, "Variable Definitions" page 18), constants (see Section 3.4, "Base Type Constants" page 15), operators, and delimiters. The ADL operator set is a near subset of the C++ operator set with a few additions and is described in the figures below.
3.7.1 Delimiters
Delimiters in the ADL primarily group together related tokens. For example, you use parentheses to change precedence within an expression. ADL delimiters have a higher precedence than operators, thereby allowing them to control the order of evaluation.
ADL Delimiters
DelimiterPair | Purpose | Sample Usage |
( ) | To change order of computation in expressions | (1+2) * 3 |
{} | To form a list from expressions | {'A, 'World, 2*3} |
[], [), (], () | To form an interval from pairs of numbers | 5 : (4,6) |
In some cases delimiters create a new semantic item out of the elements they enclose. The interval delimiters serve this purpose by making an interval from two numbers. However, intervals are more than two numbers paired together. They possess "open" or "closed" attributes at each endpoint and support a test for membership in the interval.
3.7.2 Operators
When the same operator occurs in both the ADL and in C++, it has the same semantics, precedence, and associativity. The following points deserve special notice:
- The ADL normally evaluates both subexpressions of a binary operator before calculating the result of the binary operator. However, the boolean operators (&&) and (||) present a special case. The ADL evaluates the right subexpression only if the left subexpression is TRUE in the case of (&&) and FALSE in the case of (||).
- The send message operators (=>),(|>),(?=>),and (?|>) have been overloaded to accept both objects and object handles as a second operand.
Arithmetic Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
+ | unary plus | 6 | integer, real, or time | integer, real, or time |
- | unary minus | 6 | integer, real, or time | integer, real, or time |
* | multiplication | 7 | integer or real | integer or real |
* | multiplication | 7 | (integer or real) * time | time |
/ | division | 7 | integer or real | integer or real |
/ | division | 7 | time / time | integer |
% | remainder | 7 | integer | integer or real |
+ | addition | 8 | integer, real, or time | integer, real, or time |
- | subtraction | 8 | integer, real, or time | integer, real, or time |
Relational Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
== | equal | 11 | any[5] | boolean |
!= | not equal | 11 | any | boolean |
< | less than | 11 | integer, real, or time | boolean |
<= | less than or equal to | 11 | integer, real, or time | boolean |
> | greater than | 11 | integer, real, or time | boolean |
>= | greater than or equal to | 11 | integer, real, or time | boolean |
: | is a member of interval | 11 | integer, real, or time : interval | boolean |
!: | is not a member of interval | 11 | integer, real, or time !: interval | boolean |
Boolean Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
! | not | 6 | boolean | boolean |
&& | and | 12 | boolean | boolean |
|| | or | 13 | boolean | boolean |
Function Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
() | built-in function call | 1 | any | any |
Member Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
:: | scope resolution | 1 | classname::member | any |
. | member selection | 2 | object.member | any |
-> | member selection | 2 | handle->member | any |
Handle Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
& | address of | 3 | variable or object | handle |
* | dereference | 3 | handle | variable or object |
Object Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
new | object creation | 14 | new class | handle |
delete | object destruction | 15 | delete handle | none |
clone | clone object | 3 | clone object or object handle | handle |
Metaclass Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
classOf | get handle to metaclass object | 3 | classOf object or object handle | handle |
theClass | get handle to metaclass object | 3 | theClass classname | handle |
String Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
+ | concatenate | 8 | string | string |
& | concatenate with space | 9 | string | string |
List Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
<< | append | 10 | list << any | list |
+ | concatenate | 8 | list | list |
Array Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
? | is element | 6 | array element | boolean |
remove | remove | 15 | array element | none |
Is Value Set Operator
Operator | Operation | Precedence | Type of Operands | Type of Result |
? | is value set | 6 | any | boolean |
Stream Operators
Operator | Operation | Precedence | Type of Operands | Type of Results |
<< | put | 10 | list << any object << any object << object | list object object |
>> | get | 10 | list >> any object >> any object >> object | list object object |
Message Operators
Operator | Operation | Precedence | Type of Operands | Type of Result |
=> | send synchronous message | 4 | string or list => object or object handle | any |
|> | send asynchronous message | 4 | string or list |> object or object handle | any |
?=> | send optional synchronous message | 4 | string or list ?=> object or object handle | any |
?|> | send optional asynchronous message | 4 | string or list ?|> object or object handle | any |
Resource Operators
Operator | Operation | Precedence | Type Of Operands | Type of Result |
@ | resource resolution | 5 | string | string |
Sample Expressions
3.14159 * (radius * radius) |
length("Dogs and cats") <= 255 |
userMessage + "\n" |
{ 'ResizeButton } + Args |> myButton |
(oldWidth == ( 'GetWidth => myButton )) |
[5] Any implies any base or compound data type. The equal and not equal operators can also be applied to arrays (Section 3.9, "Complex Data Types" page 25), but not to objects.
- 3.7.1 - Delimiters
-
- 3.7.2 - Operators
-
AM2 Documentation - 19 NOV 1996
Generated with Harlequin WebMaker