Ada Programming/Operators
Standard operators
editAda 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
editRelational operators
edit- /=
- Not Equal , (also special character /=)
- =
- Equal , (also special character =)
- <
- Less than , (also special character <)
- <=
- Less than or equal to ( ), (also special character <=)
- >
- Greater than ( ), (also special character >)
- >=
- Greater than or equal to ( ), (also special character >=)
Binary adding operators
edit- +
- Add , (also special character +)
- -
- Subtract , (also special character -)
- &
- Concatenate , & , (also special character &)
Unary adding operators
editMultiplying operator
edit- *
- Multiply, , (also special character *)
- /
- Divide , (also special character /)
- mod
- modulus (also keyword mod)
- rem
- remainder (also keyword rem)
Highest precedence operator
editShort-circuit control forms
editThese are not operators and thus cannot be overloaded.
Membership tests
editThe Membership Tests also cannot be overloaded because they are not operators.
- in
- element of, , e.g.
, (also keywordif
Iin
Positivethen
in
) - not in
- not element of, , e.g.
, (also keywordsif
Inot
in
Positivethen
not
in
)
Range membership test
editif
Todaynot
in
Tuesday .. Thursdaythen
...
Subtype membership test
editIs_Non_Negative := X in
Natural;
Class membership test
editexit
when
Objectin
Circle'Class;
Range membership test
editif
Todaynot
in
Tuesday .. Thursdaythen
...
Choice list membership test
editThis language feature has been introduced in Ada 2012.
Ada 2012 extended the membership tests to include the union (short-circuit or) of several range or value choices.
if
Todayin
Monday .. Wednesday | Fridaythen
...
See also
editWikibook
editAda 95 Reference Manual
editAda 2005 Reference Manual
editAda Quality and Style Guide
edit
Ada Operators | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|