Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help


4.5.3 Binary Adding Operators

Static Semantics
(1)
The binary adding operators + (addition) and - (subtraction) are predefined for every specific numeric type T with their conventional meaning. They have the following specifications:
(2)
       function "+"(Left, Right : T) return T
       function "-"(Left, Right : T) return T
(3)
The concatenation operators & are predefined for every nonlimited, one-dimensional array type T with component type C. They have the following specifications:
(4)
       function "&"(Left : T; Right : T) return T
       function "&"(Left : T; Right : C) return T
       function "&"(Left : C; Right : T) return T
       function "&"(Left : C; Right : C) return T
Dynamic Semantics
(5)
For the evaluation of a concatenation with result type T, if both operands are of type T, the result of the concatenation is a one-dimensional array whose length is the sum of the lengths of its operands, and whose components comprise the components of the left operand followed by the components of the right operand. If the left operand is a null array, the result of the concatenation is the right operand. Otherwise, the lower bound of the result is determined as follows:
(6)
(7)
(8)
The upper bound is determined by the lower bound and the length. A check is made that the upper bound of the result of the concatenation belongs to the range of the index subtype, unless the result is a null array. Constraint_Error is raised if this check fails.
(9)
If either operand is of the component type C, the result of the concatenation is given by the above rules, using in place of such an operand an array having this operand as its only component (converted to the component subtype) and having the lower bound of the index subtype of the array type as its lower bound.
(10)
The result of a concatenation is defined in terms of an assignment to an anonymous object, as for any function call (see 6.5).

(11)
Examples
(12)
Examples of expressions involving binary adding operators:
(13)
       Z + 0.1      --  Z has to be of a real type
(14)
       "A" & "BCD"  --  concatenation of two string literals
       'A' & "BCD"  --  concatenation of a character literal and a string literal
       'A' & 'A'    --  concatenation of two character literals

Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help

Ada WWW Home -- Email comments, additions, corrections, gripes, kudos, etc. to:

Magnus Kempe -- Magnus.Kempe@di.epfl.ch
Copyright statement
Page last generated: 95-03-12