Language Operators
From dis-Emi-A
To prevent confusion and to improve readability we will state that each operator has to be distinct in its meaning and have the same meaning for all its supported types. Though this cannot be enforced in third party libraries, it will be stated as a requirement for compliant code and will be followed in all standard libraries.
Unicode symbols are provided as maps to the preferred Unicode Source Format.
Note that some operators are being defined which may not be intended to be part of the standard operators of the language, but have nonetheless been reserved for a particular purpose.
Contents |
Numeric Operators
| ASCII | Unicode | Description | Example |
|---|---|---|---|
| + | B; | addition | 5 + 3 == 8 |
| - | ࢤ | subtraction | 5 - 3 == 2 |
| / | ࢧ | division | 10 / 4 == 2.5 |
| * | �D7; | multiplication | 2.5 * 3 == 7.5 |
| ^ | exponent | 2 ^ 3 == 8 | |
| - | unary negative | -( 2 + 3 ) == -5 |
Comparitive Operators
The restriction about being distinct in meaning is loosened a bit for comparitive operators as it is easy to have the same abstract meaning with completely distinct types. It is however still incorrect to use these operators to compare types that do not exist as part of the same type system (only like types may be compared in this fashion).
Comparitive binary operators take two operands and return a boolean truth value for the relationship.
| ASCII | Unicode | Description | Types | Example |
|---|---|---|---|---|
| < | < | less than / preceeds | T,T => bool | a < b |
| > | > | greater than / succeeds | T,T => bool | a > b |
| == | ࣕ | equal to / same as | T,T => bool | a == b |
| != | ࣔ | not equal to / differ | T,T => bool | a != b |
| <= | ࣘ | less than or equal to | T,T => bool | a <= b |
| >= | ࣙ | greater than or equal to | T,T => bool | a >= b |
Logical Operators
Note that operators with the same precedence either define a n-ary operator or need to be bracketed. That means that the typical && or || can both be used with n-ary sequences of arguements. (Though for these two items the difference between left/right evaluation and set evaluation is nil.)
Some of these logical operators may have little use in procedural code but play a more significant role in constraints.
Type: bool _op_ bool [ _op_ bool ]* => bool (except for ¬ which is unary)
| ASCII | Unicode | Description | Example |
|---|---|---|---|
| && | ? | conjunction / and | a && b |
| || | ? | disjunction / or | a || b |
| ^^ | ? | xor | a ^^ b |
| !& | bc; | nand | a !& b |
| => | ? | material implication | a && b => c || d |
| <=> | ? | material equivalence | a && b <=> c || d (a && b) == (c || d) |
| ! | ¬ | negation | !a |
Is material equivalence needed since one can always group expressions and use the equivalence operator. In constraints the material equivalence is more appropriate however, and is guarantees to use only boolean values...?
Should quantification operators be added as standard? ? and ? (they should fit naturally into the : filter syntax)
Set Operators
| ASCII | Unicode | Description | Example |
|---|---|---|---|
| in | ࢠ | set element assignment | [ a in b ] { stdout << a << endl; } |
| : | : | such that / filter | even = b : ( b mod 2 == 0 ) |
Vector / Matrix Operators
| ASCII | Unicode | Description | Example |
|---|
Stream Operators
| ASCII | Unicode | Description | Example |
|---|
Assignment Operators
| ASCII | Unicode | Description | Example |
|---|---|---|---|
| : | assignment | a : 5 muldiv : x, y, z -> x * y / z ; |
Keywords/Tokens
This is included here as they seem like operators but they have a very different effect on the system than typical operators.
| ASCII | Unicode | Description | Example |
|---|---|---|---|
| [ ... ] | [ ... ] | [ a != 4 ] { ... } |
