Ada Programming/Operators

Standard operators
Ada allows operator overloading for all standard operators and so the following summaries can only describe the suggested standard operations for each operator. It is quite possible to misuse any standard operator to perform something unusual.

Each operator is either a keyword or a delimiter—hence all operator pages are redirects to the appropriate keyword or delimiter.

Operators have arguments which in the RM are called Left and Right for binary operators, Right for unary operators (indicating the position with respect to the operator symbol).

The list is sorted from lowest precedence to highest precedence.

Logical operators

 * and : and $$x \land y$$, (also keyword and)
 * or : or $$x \lor y$$, (also keyword or)
 * xor : exclusive or $$(x \land \bar{y}) \lor (\bar{x} \land y)$$, (also keyword xor)

Relational operators

 * /= : Not Equal $$x \ne y$$, (also special character /=)
 * = : Equal $$x = y$$, (also special character =)
 * < : Less than $$x : Greater than ($$x > y$$), (also special character >)
 * >= : Greater than or equal to ($$x \ge y$$), (also special character >=)

Binary adding operators

 * + : Add $$x + y$$, (also special character +)
 * - : Subtract $$x - y$$, (also special character -)
 * & : Concatenate, $$x$$ & $$ y$$, (also special character &)

Unary adding operators

 * + : Plus sign $$+x$$, (also special character +)
 * - : Minus sign $$-x$$, (also special character -)

Multiplying operator

 * * : Multiply, $$x \times y$$, (also special character *)
 * / : Divide $$x / y$$, (also special character /)
 * mod : modulus (also keyword mod)
 * rem : remainder (also keyword rem)

Highest precedence operator

 * ** : Power $$x^y$$, (also special character **)
 * not : logical not $$\lnot x$$, (also keyword not)
 * abs : absolute value $$|x|$$ (also keyword abs)

Short-circuit control forms
These are not operators and thus cannot be overloaded.


 * and then : e.g.
 * or else : e.g.

Membership tests
The Membership Tests also cannot be overloaded because they are not operators.


 * in : element of, $$var \in type$$, e.g. , (also keyword )
 * not in : not element of, $$var \notin type$$, e.g. , (also keywords  )

Range membership test
Today  Tuesday .. Thursday ...

Subtype membership test
Is_Non_Negative := X Natural;

Class membership test
Object Circle';

Range membership test
Today  Tuesday .. Thursday ...

Choice list membership test
Ada 2012 extended the membership tests to include the union (short-circuit or) of several range or value choices.

Today Monday .. Wednesday | Friday ...

Wikibook

 * Ada Programming

Ada Quality and Style Guide


|Operators

Programación en Ada/Operadores