Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements for bitwise, logical and comparison operators #6

Merged
merged 11 commits into from
Aug 20, 2016
Merged

Improvements for bitwise, logical and comparison operators #6

merged 11 commits into from
Aug 20, 2016

Conversation

mheinzel
Copy link
Contributor

1 ^ 2 ^ 3 works now.
Logical operators (or, and) only evaluate the second argument if necessary (short-circuiting). This also works with truthiness.

You can see examples for these things in the tests I added.

I am currently working on comparisons, there is a lot missing (e.g. comparison of bools, lists, strings, equality of sets and lists). I think it would be best to base it on the methods __eq__() etc., but that would require some work.
Also, chained comparison is not supported yet (e.g. 1 < 2 < 3 > 0). I am thinking about it, but it's not really straight-forward to implement.

Generators, list/generator/tuple comprehensions, and splat/star-args are waiting as well, so there is enough to do :D

Matthias

@mheinzel mheinzel changed the title Improvements for bitwise and logical operators Improvements for bitwise, logical and comparison operators Aug 12, 2016
@mheinzel
Copy link
Contributor Author

I implemented equality and comparison for many different types. There is some duplication between equal and compareObjs, but that is hard to avoid (one reason are cyclic dependencies). Maybe I will base it on __eq__() etc. one day.

And I got chained comparison operators down! Such a good feeling. 😄
1 < 2 < 3 means 1 < 2 and 2 < 3, but you cannot evaluate the part in the middle twice. If there is a function with side-effects, it will change the meaning of the program.

@mattgreen
Copy link
Owner

Sorry for the delay, I've been on vacation and am still getting back into real life. :)

Great work on all of these! I need to study some of the commits some more.

@mattgreen mattgreen merged commit 40ba2aa into mattgreen:master Aug 20, 2016
@mheinzel
Copy link
Contributor Author

No problem, just take your time! If there is anything unclear or you are not happy with something, don't hesitate to ask me about it.

@mheinzel mheinzel deleted the bitwise-and-boolean-operators branch August 31, 2016 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants