Chapter 3 The Application Description Language
3.11 Type Conversion
Type conversion happens in the following instances:
- Assignment
- Arguments to built-in function calls
- Arguments to messages
- Promotion in arithmetic and numerical relational expressions
In the first three cases integers convert to reals, and reals truncate to integers, as indicated by the associated type declarations. Strings are not automatically converted to numeric values. You can use the ADL built-in functions (see Section 3.12, "Built-in Function Calls" page 29) toInteger()and toReal() to perform explicit conversions. In the case of promotion in expressions, any binary operator with one integer and one real operand promotes the integer operand to real before performing the operation. Certain compound types are also implicitly converted.
- A time converts to an integer, a real, or a list as required, and vice versa. The integer or real version of a time contains the corresponding number of milliseconds. The list version contains four elements: hours, minutes, seconds, and milliseconds.
- An interval implicitly converts to a list, and an appropriately formatted list to an interval (see Section 3.5, "Compound Types" page 16). An error results if you attempt to convert an inappropriate list to an interval or time.
The only other case of promotion occurs when a string on the left hand side of a send message operator is promoted to a one member list. (see Section 3.13, "Messages" page 30).
AM2 Documentation - 19 NOV 1996
Generated with Harlequin WebMaker