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

Missing boolean NOT operator #72

Closed
cardillan opened this issue Jan 16, 2023 · 1 comment
Closed

Missing boolean NOT operator #72

cardillan opened this issue Jan 16, 2023 · 1 comment

Comments

@cardillan
Copy link
Owner

cardillan commented Jan 16, 2023

Currently, there isn't a boolean negation operator. Both negation operators that are currently defined (! and not) compile to an op flip/not instruction (the operator is called "flip" in GUI and "not" in Mindustry "assembly" language), which produces bitwise negation. This means that the following code

while not switch1.enabled
    print("Press the button to start...")
    printflush(message1)
end

won't work (switch1.enabled produces 1 when the button is pressed, and bitwise negation makes it into -2).

I propose creating a new unary operator ~ for bitwise negation, and repurposing both ! and not for boolean negation. However, this change could break existing code. @francois, shall I do this?

@francois
Copy link
Collaborator

Yes, you can go ahead.

This issue was closed.
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

No branches or pull requests

2 participants