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

allow double bang (double boolean_not) #129

Merged
merged 3 commits into from
Jun 17, 2024
Merged

Conversation

tinygiant98
Copy link
Contributor

Allows double boolean_not (!!x) without requiring the second booelan_not to be enclosed in parenthesis (i.e. !(!x)).

Testing

Tested the following use cases:

  • Single bang (boolean_not) -> !x
  • Double bang -> !!x
  • Parenthesized double bang -> !(!x)
  • Multiple bangs -> !!!x
  • Passed as a parameter -> my_function(!!x)

Changelog

Added

  • Allow use of double-bang to "booleanize" a constant/variable integer value without requiring the second boolean negation to be parenthesized.

Licence

  • I am licencing my change under the project's MIT licence, including all changes to GPL-3.0 licenced parts of the codebase.

Allows double boolean_not (`!!x`) without requiring the second
booelan_not to be enclosed in parenthesis (i.e. `!(!x)`).
@tinygiant98
Copy link
Contributor Author

tinygiant98 commented Jun 16, 2024

Exceptionally minor changes could also allow the following constructs, but I didn't add them in because they could be useless/confusing/undesired:

  • Double unary negation (- -7)
  • Boolean_not followed by decrement (!--)
  • Boolean_not followed by increment (!++)

If anyone thinks these would be useful/desireable, I can add them in.

@mtijanic mtijanic merged commit 1b04117 into niv:master Jun 17, 2024
2 checks passed
@tinygiant98 tinygiant98 deleted the double-bang branch December 1, 2024 20:54
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