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

make boolean functions return a boolean #3123

Open
markus2330 opened this issue Oct 28, 2019 · 0 comments
Labels

Comments

@markus2330
Copy link
Contributor

@markus2330 markus2330 commented Oct 28, 2019

As discussed in #3111 @kodebach proposes:

The return type isn't that important actually. The main point is that functions like keyIsBelow should only return 0 or 1 but never -1 to make it harder to use it wrongly in ifs. A boolean return type just makes it more obvious that this should be the case.

The fix for this actually quite easy, we would only need to define the "belowness" of null pointers (also in the docu). One way to define it, would be to always return false (0) if any null pointer is involved (so simply not distinguish API errors and below checks, i.e., map -1 to 0).

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.