Virgil I-01
All operators in Virgil are strict (all operands are evaluated before performing the operation), unless specified otherwise. Order of evaluation for all operators is left to right. The initial version of the Virgil language, version I-01, defines the following set of operators:
Boolean operators
andbinary infix(boolean, boolean) -> boolean
Denotes the logical and operation on booleans. Lazy: in the expressionA and B, the expressionBis only evaluated ifAevaluates totrue.orbinary infix(boolean, boolean) -> boolean
Denotes the logical or operation on booleans. Lazy: in the expressionA or B, the expressionBis only evaluated ifAevaluates tofalse.!unary prefix(boolean) -> boolean
Denotes the logical not operation on booleans.
Integer operators
+binary infix(int, int) -> int
Denotes the integer addition operation on integers. Overflow or underflow semantics are dictated by standard 32-bit two's complement arithmetic.-binary infix(int, int) -> int
Denotes the integer subtraction operation on integers. Overflow or underflow semantics are dictated by standard 32-bit two's complement arithmetic.*binary infix(int, int) -> int
Denotes the integer multiplication operation on integers. Overflow or underflow semantics are dictated by standard 32-bit two's complement arithmetic./binary infix(int, int) -> int
Denotes the integer division operation on integers. Overflow or underflow semantics are dictated by standard 32-bit two's complement arithmetic. Generates aDivideByZeroExceptionif the second operand has integer value0.<binary infix(int, int) -> boolean
Denotes the integer less than comparison operation on integers.<=binary infix(int, int) -> boolean
Denotes the integer less than or equal comparison operation on integers.>binary infix(int, int) -> boolean
Denotes the integer greater than comparison operation on integers.>=binary infix(int, int) -> boolean
Denotes the integer greater than comparison operation on integers.-unary prefix(int) -> int
Denotes the integer complement operation on integers. Semantics are defined by standard 32-bit two's complement operation.
Character operators
<binary infix(char, char) -> boolean
Denotes the character less than comparison operation on characters.<=binary infix(char, char) -> boolean
Denotes the character less than or equal comparison operation on integers.>binary infix(char, char) -> boolean
Denotes the character greater than comparison operation on characters.>=binary infix(char, char) -> boolean
Denotes the character greater than comparison operation on characters.
Type operators
-
instanceof Tpolymorphic unary postfix(X) -> boolean
Denotes the dynamic type query (instanceof) operation on objects. Retrieves the dynamic type of object,Dand tests whetherDis a subtype of the specified typeT. -
<: Tpolymorphic unary postfix(X) -> boolean
Equivalent toinstanceof T. :: Tpolymorphic unary postfix(X) -> T(withTsubclass ofX)
Denotes the dynamic type cast (cast) operation on objects. Retrieves the dynamic type of object,Dand tests whetherDis a subtype of the specified typeT. Generates aTypeCheckExceptionif the test fails.:: Tpolymorphic unary postfix(X) -> T(withXconvertible toT)
Denotes the explicit value conversion (convert) operation on value types such asint. See language specification for details on legal conversions.
Comparison operators
-
==polymorphic binary infix(X, Y) -> boolean(withXandYcomparable)
Denotes the value equality operation on values. For details on legal value comparisons, see the language specification. -
!=polymorphic binary infix(X, Y) -> boolean(withXandYcomparable)
Denotes the value inequality operation on values. For details on legal value comparisons, see the language specification.
Raw operators
&binary infix(m, n) -> min(m, n)(withmandnraw)
Denotes the bitwise and operation on raw values.|binary infix(m, n) -> max(m, n)(withmandnraw)
Denotes the bitwise or operation on raw values.^binary infix(m, n) -> max(m, n)(withmandnraw)
Denotes the bitwise exclusive-or operation on raw values.<<binary infix(m, int) -> m(withmraw)
Denotes the shift left operation within a window ofmbits on raw values.>>binary infix(m, int) -> m(withmraw)
Denotes the shift right operation within a window ofmbits on raw values.#binary infix(m, n) -> m+n(withmandnraw)
Denotes the bitwise concatentation operation on raw values.[]e[e](m, int) -> 1(withmraw)
Denotes the bit access operation, which retrieves a single bit from the specified value. If the index is out of bounds, this operation will return the raw value0without generating an exception.