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

Const-correctness #215

Closed
genemerewether opened this issue Jun 8, 2023 · 2 comments · Fixed by #327
Closed

Const-correctness #215

genemerewether opened this issue Jun 8, 2023 · 2 comments · Fixed by #327

Comments

@genemerewether
Copy link

Hi, is there a policy / upcoming work on const versions of API functions, where reasonable?

i.e. const accessors for internal::Unique, const pointers in function prototypes where the underlying data is not modified, or where a const flavor of e.g. ArrowArrayView could be used instead?

@paleolimbot
Copy link
Member

I honestly just haven't thought about it! Most current usage/testing is in C right now where const-ness isn't quite as baked in to the language.

One first step is could be to go through the C API functions and declare pointers that are not modified as const...there are quite a few of them but mostly that lives in documentation at this point and not as const declarations.

@paleolimbot paleolimbot added this to the nanoarrow 0.3.0 milestone Jun 13, 2023
@paleolimbot
Copy link
Member

Just a note that I'm bumping this to 0.4 because it would result in a lot of compiler warnings for any project that was using a development version between 0.2 and 0.3 (and because the 0.3 release is forthcoming!).

This has come up a few times in existing usage...declaring input pointers (e.g., ArrowSchema*) in the C API as const ArrowSchema* is also a helpful way to communicate that the function will not take ownership of the schema.

paleolimbot added a commit that referenced this issue Nov 29, 2023
…larations (#327)

A number of functions accept pointers (e.g., `ArrowSchema*`) but do not
take ownership of the argument or modify it in any way. To better
communicate this, this PR adds `const` before all possible parameters
that are not modified by the function.

Closes #215.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants