operator overload

pull/14/head
pca006132 2020-12-23 16:53:01 +08:00 committed by pca006132
parent fdaf8d8661
commit 4abe22bcf2
1 changed files with 32 additions and 1 deletions

View File

@ -21,6 +21,11 @@ for simplicity reasons:
* method override check modulo variable renaming.
* more complicated type guard
## Running Example
```bash
python main.py example/a.py
```
## Files
All files named `test_xxx` are used for inspecting the result of algorithms, and
can be ignored for now.
@ -198,5 +203,31 @@ This would fail. From the first argument, we have `A -> A`, and from the second
argument we need `A -> B`. In general, we may have `A != B`, so there is no
substitution that meets the requirement and the type check failed.
## Operator Override
## Operator Overloading
Most operations are actually implemented via operator overloading.
We currently support:
* Normal:
* `__init__`
* Comparison:
* `__lt__`
* `__le__`
* `__gt__`
* `__ge__`
* `__eq__`
* `__ne__`
* Arithmetic:
* `__add__`
* `__sub__`
* `__mul__`
* `__matmul__`
* `__truediv__`
* `__floordiv__`
* `__mod__`
* `__pow__`
* `__lshift__`
* `__rshift__`
* `__and__`
* `__or__`
* `__xor__`
* `__neg__`