charly-vm
charly-vm copied to clipboard
Operator overloading
- Major operators should be overloadable to implement custom domain-specific operations
- Some keywords should be overloadable, like
await - Some language constructs should be overloadable
- Index access / call operation
- Operator functions cannot be made static
class Vec2 {
property x
property y
operator +(other) {
Vec2(x + other.x, y + other.y)
}
operator -(other) {
Vec2(x - other.x, y - other.y)
}
operator [](index) {
// index access
}
operator []=(index, value) {
// index assignment
}
operator ()(args) {
// call operator
}
}