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
and
binary infix(boolean, boolean) -> boolean
Denotes the logical and operation on booleans. Lazy: in the expressionA and B
, the expressionB
is only evaluated ifA
evaluates totrue
.or
binary infix(boolean, boolean) -> boolean
Denotes the logical or operation on booleans. Lazy: in the expressionA or B
, the expressionB
is only evaluated ifA
evaluates 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 aDivideByZeroException
if 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 T
polymorphic unary postfix(X) -> boolean
Denotes the dynamic type query (instanceof) operation on objects. Retrieves the dynamic type of object,D
and tests whetherD
is a subtype of the specified typeT
. -
<: T
polymorphic unary postfix(X) -> boolean
Equivalent toinstanceof T
. :: T
polymorphic unary postfix(X) -> T
(withT
subclass ofX
)
Denotes the dynamic type cast (cast) operation on objects. Retrieves the dynamic type of object,D
and tests whetherD
is a subtype of the specified typeT
. Generates aTypeCheckException
if the test fails.:: T
polymorphic unary postfix(X) -> T
(withX
convertible 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
(withX
andY
comparable)
Denotes the value equality operation on values. For details on legal value comparisons, see the language specification. -
!=
polymorphic binary infix(X, Y) -> boolean
(withX
andY
comparable)
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)
(withm
andn
raw)
Denotes the bitwise and operation on raw values.|
binary infix(m, n) -> max(m, n)
(withm
andn
raw)
Denotes the bitwise or operation on raw values.^
binary infix(m, n) -> max(m, n)
(withm
andn
raw)
Denotes the bitwise exclusive-or operation on raw values.<<
binary infix(m, int) -> m
(withm
raw)
Denotes the shift left operation within a window ofm
bits on raw values.>>
binary infix(m, int) -> m
(withm
raw)
Denotes the shift right operation within a window ofm
bits on raw values.#
binary infix(m, n) -> m+n
(withm
andn
raw)
Denotes the bitwise concatentation operation on raw values.[]
e[e](m, int) -> 1
(withm
raw)
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 value0
without generating an exception.