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 integer handles use non-zero types #137

Merged
merged 2 commits into from
Aug 8, 2023
Merged

Make integer handles use non-zero types #137

merged 2 commits into from
Aug 8, 2023

Conversation

madsmtm
Copy link
Member

@madsmtm madsmtm commented Jul 30, 2023

In similar spirit as #136.

I'm not sure myself that this is such a good idea, mainly because:

  • The c_int/c_long types are not possible to convert to non-zero types in the same manner (leading to us only using the API in some places).
  • Ensuring non-null pointers is important, since that causes unsoundness if used incorrectly, while a zero handle isn't that big of a problem, any operations you do on them will just error (just like any other invalid handle).

Other options would be to panic on 0 in the constructor (a weak check against invalid handles, assuming those are exceedingly rare), or we could document that it is a bug in the implementer (as opposed to the consumer) to provide zero handles where unexpected?

Copy link
Member

@notgull notgull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@notgull notgull merged commit 245664a into nonnull Aug 8, 2023
@notgull notgull deleted the nonzero branch August 8, 2023 21:44
@madsmtm
Copy link
Member Author

madsmtm commented Aug 9, 2023

Uh, I kinda wanted to debate this after #136, but oh well

@notgull
Copy link
Member

notgull commented Aug 9, 2023

Oh, my bad, there weren't any comments for a while so I assumed that the debate was settled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants