JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
88 stars 4 forks source link

Add bitwise operators #109

Closed JSAbrahams closed 5 years ago

JSAbrahams commented 5 years ago

Current Issue

There are no bitwise operators

Description of the feature

Add bitwise operators.

Description of potential solution

Add tokens for these operators, and modify the pipeline accordingly. Since bitwise operators are a more advanced feature, I think that it's okay to let them be the same as in Python. So, & in Python is & in Mamba, | in Python | in Mamba, etc.

JSAbrahams commented 5 years ago

While implementing I noticed that operator precedence is not explicitly defined. We need some tests for this and to update the documentation. In cases where it does deviate from the precedence in Python, it should be clearly motivated I believe. For instance, and and or have higher precedence than comparison operators such as > and <. But why?

JSAbrahams commented 5 years ago

Eventually, in part due to conflicts with the current syntax, and the philosophy of Mamba, I opted to use: _not_ for bitwise not, as opposed to ~ _and_ instead of & _or_ instead of | _xor_ instead of ^