-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Status
Nothing implemented yet.
Just leaving it here for further updates and notes.
TBD.
Conversion operators parse.
Started implementing them, the progress is saved on the experimental-operator-overloading branch.
Checklist
- In-class syntax, maybe outside of classes too
- Syntax parsing
- Proper implementation of simple operator overloading (See Implementation idea)
- ??? Probably template operator overloading
Syntax idea
This is how a method declaration looks right now:
class Ooga {
fooga(arg: Int32) {
ret 5 + 1;
}
}I suggest this syntax for operators:
class Ooga {
operator ==(arg: Int32) {
return arg == 1;
}
}For a differentation between prefix and postfix I suggest special keywords pre and post (the C++ approach of putting an int parameter is simply weird and misleading):
class Ooga {
operator post ++ {
return ;
}
operator pre ++ {
return ;
}
}(The idea of having pre and post operators may be completely ditched)
For conversion operators this syntax has been decided upon:
class Ooga {
operator as Int32 { return 5; }
}Implementation idea
Every operator goes through the same function in ExpressionExecutor.
Each operator generally does some kind of preprocessing first.
I suggest that each operator does it's preprocessing and calls a special function that looks for operator overloads for a type, with the types provided by the caller.
If it fails, it throws a runtime error, if it succeeds, it returns the result of calling that function.
Syntax preview
Nothing yet.