Contents Index Search Previous Next

1

{*expression*} An
*expression* is a formula that defines the computation or retrieval
of a value. In this International Standard, the term ``expression'' refers
to a construct of the syntactic category expression
or of any of the other five syntactic categories defined below. {*and
operator*} {*operator
(and)*} {*or operator*}
{*operator (or)*} {*xor
operator*} {*operator
(xor)*} {*and then (short-circuit
control form)*} {*or
else (short-circuit control form)*} {*=
operator*} {*operator
(=)*} {*equal operator*}
{*operator (equal)*}
{*/= operator*} {*operator
(/=)*} {*not equal operator*}
{*operator (not equal)*}
{*< operator*} {*operator
(<)*} {*less than
operator*} {*operator
(less than)*} {*<=
operator*} {*operator
(<=)*} {*less than
or equal operator*} {*operator
(less than or equal)*} {*>
operator*} {*operator
(>)*} {*greater than
operator*} {*operator
(greater than)*} {*>=
operator*} {*operator
(>=)*} {*greater than
or equal operator*} {*operator
(greater than or equal)*} {*in
(membership test)*} {*not
in (membership test)*} {*+
operator*} {*operator
(+)*} {*plus operator*}
{*operator (plus)*} {*-
operator*} {*operator
(-)*} {*minus operator*}
{*operator (minus)*}
{*& operator*} {*operator
(&)*} {*ampersand
operator*} {*operator
(ampersand)*} {*concatenation
operator*} {*operator
(concatenation)*} {*catenation
operator: See concatenation operator*} {**
operator*} {*operator
(*)*} {*multiply operator*}
{*operator (multiply)*}
{*times operator*} {*operator
(times)*} {*/ operator*}
{*operator (/)*} {*divide
operator*} {*operator
(divide)*} {*mod operator*}
{*operator (mod)*} {*rem
operator*} {*operator
(rem)*} {*** operator*}
{*operator (**)*} {*exponentiation
operator*} {*operator
(exponentiation)*} {*abs
operator*} {*operator
(abs)*} {*absolute value*}
{*not operator*} {*operator
(not)*}

2

expression
::=

relation {**and** relation} | relation {**and** **then** relation}

| relation {**or** relation} | relation {**or** **else** relation}

| relation {**xor** relation}

relation {

| relation {

| relation {

3

relation
::=

simple_expression [relational_operator simple_expression]

| simple_expression [**not**] **in** range

| simple_expression [**not**] **in** subtype_mark

simple_expression [relational_operator simple_expression]

| simple_expression [

| simple_expression [

4

5

6

7

primary
::=

numeric_literal |**null** | string_literal | aggregate

| name | qualified_expression | allocator | (expression)

numeric_literal |

| name | qualified_expression | allocator | (expression)

8

A name used
as a primary shall resolve to denote
an object or a value.

8.a

8.b

9

Each expression has a type; it specifies the computation
or retrieval of a value of that type.

10

{*evaluation (primary that
is a name)* [partial]} The value of a primary
that is a name denoting an object
is the value of the object.

11

{*Overflow_Check* [partial]}
{*check, language-defined (Overflow_Check)*}
{*Constraint_Error (raised by failure
of run-time check)*} For the evaluation
of a primary that is a name
denoting an object of an unconstrained numeric subtype, if the value
of the object is outside the base range of its type, the implementation
may either raise Constraint_Error or return the value of the object.

11.a

11.b

11.c

12

13

Pi

(1 .. 10 => 0)

Sum

Integer'Last

Sine(X)

Color'(Blue)

Real(M*N)

(Line_Count + 10)

14

15

2*Line_Count

-4.0

-4.0 + A

B**2 - 4.0*A*C

Password(1 .. 3) = "Bwv"

Count

Count

Index = 0

(Cold

A**(B**C)

15.a

{*extensions to Ada 83*}
In Ada 83, **out** parameters and their nondiscriminant
subcomponents are not allowed as primaries.
These restrictions are eliminated in Ada 95.

15.b

In various contexts throughout
the language where Ada 83 syntax rules had simple_expression,
the corresponding Ada 95 syntax rule has expression
instead. This reflects the inclusion of modular integer types, which
makes the logical operators "**and**", "**or**",
and "**xor**" more useful in expressions of an integer type.
Requiring parentheses to use these operators in such contexts seemed
unnecessary and potentially confusing. Note that the bounds of a range
still have to be specified by simple_expressions,
since otherwise expressions involving
membership tests might be ambiguous. Essentially, the operation ".."
is of higher precedence than the logical operators, and hence uses of
logical operators still have to be parenthesized when used in a bound
of a range.