Operators

Power Function

Boolean Operators

Equality

Range Operator .. and ..<

Bit-Shift & Rotation

Operator Declaration

Assignment Operator

class Int256 {
    operator =(Int256 other) { ... }
}

Arithmetic Operators

operator +(Int256 a, b) -> Int256 { ... }
operator -(Int256 a, b) -> Int256 { ... }
operator *(Int256 a, b) -> Int256 { ... }
operator /(Int256 a, b) -> Int256 { ... }
operator %(Int256 a, b) -> Int256 { ... }

Shift and Rotate Operators

operator <<(Int256 a, Int shiftCount) -> Int256 { ... }
operator >>(Int256 a, Int shiftCount) -> Int256 { ... }
operator <<<(UInt256 a, Int shiftCount) -> UInt256 { ... }
operator >>>(UInt256 a, Int shiftCount) -> UInt256 { ... }

Compound Assignment Operators

class Int256 {
    operator +=(Int256 other) { ... }
    operator -=(Int256 other) { ... }
    operator *=(Int256 other) { ... }
    operator /=(Int256 other) { ... }
    operator %=(Int256 other) { ... }
    operator <<=(Int shiftCount) { ... }
    operator >>=(Int shiftCount) { ... }
    operator &=(Int256 other) { ... }
    operator |=(Int256 other) { ... }
}
class UInt256 {
    operator <<<=(Int shiftCount) { ... }
    operator >>>=(Int shiftCount) { ... }
}

Increment and Decrement Operators

class Int256 {
    operator ++() -> Int256& { ... }
    operator ++(Int dummy) -> Int256 { ... } // post-increment
    operator --() -> Int256& { ... }
    operator --(Int dummy) -> Int256 { ... } // post-decrement
}

Relational and Comparison Operators

operator ==(Int256 a, b) -> Bool { ... }
operator !=(Int256 a, b) -> Bool { ... }
operator <(Int256 a, b) -> Bool { ... }
operator >(Int256 a, b) -> Bool { ... }
operator <=(Int256 a, b) -> Bool { ... }
operator >=(Int256 a, b) -> Bool { ... }
operator <=>(Int256 a, b) -> Int { ... }

Logical Operators

Subscript/Bracket Operator

class MyArray<type T> {
    // Array subscript
    operator [Int i] -> T& {
        return data[i]
    }
}
class MyImage<type T> {
    // 2D array (i.e. image like) subscript
    operator [Int x, y] -> T& {
        return data[x + y*stride]
    }
}

Parenthesis/Functor Operator

class MyFunctor {
    // Functor call
    operator (Int a, Float b, String c) {
        ...
    }
}