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

[C++] The difference between namespace detail and internal #45808

Open
arashandishgar opened this issue Mar 15, 2025 · 4 comments
Open

[C++] The difference between namespace detail and internal #45808

arashandishgar opened this issue Mar 15, 2025 · 4 comments
Labels
Component: C++ Type: usage Issue is a user question

Comments

@arashandishgar
Copy link
Contributor

Describe the usage question you have. Please include as many useful details as possible.

I found that Arrow uses two groups of namespace for separating APIs from the public the names of which are internal and detail. What's the difference between them?

Component(s)

C++

@arashandishgar arashandishgar added the Type: usage Issue is a user question label Mar 15, 2025
@kou kou changed the title namespace detail vs internal [C++] namespace detail vs internal Mar 16, 2025
@kou
Copy link
Member

kou commented Mar 16, 2025

@pitrou Do you have any preference? It seems that the Google C++ Style Guide uses internal not detail:

https://google.github.io/styleguide/cppguide.html#Namespaces

Use namespaces with "internal" in the name to document parts of an API that should not be mentioned by users of the API.

@pitrou
Copy link
Member

pitrou commented Mar 16, 2025

I think that I've used detail for implementation details that leak into public APIs (for example, a base class for public API classes). No strong feeling from me, though. We could perhaps make our conventions simpler.

@felipecrv @bkietz What do you think?

@bkietz
Copy link
Member

bkietz commented Mar 16, 2025

My understanding has always been that detail implies "shouldn't be necessary for users" while internal implies "danger for users".

I think it'd be fine to just use internal for anything we don't intend users to touch

@arashandishgar arashandishgar changed the title [C++] namespace detail vs internal [C++] The difference between namespace detail and internal Mar 17, 2025
@felipecrv
Copy link
Contributor

felipecrv commented Mar 19, 2025

My understand has always been arrow::internal can leak into headers, but arrow::detail is for details within a .cc (compilation unit).

arrow::internal APIs MUST be present in headers because to implement public APIs across different .cc files, we need the internal APIs.

Number of .h and .cc where these names occur:

~/code/arrow (main)$ ag "\bdetail\b" -l | egrep "\.cc$" | wc -l
      50
 ~/code/arrow (main)$ ag "\bdetail\b" -l | egrep "\.h$" | wc -l
      46
~/code/arrow (main)$ ag "\binternal\b" -l | egrep "\.h$" | wc -l
     304
 ~/code/arrow (main)$ ag "\binternal\b" -l | egrep "\.cc$" | wc -l
     600

Which is very similar to @bkietz explanation:

detail = unnecessary for users
internal = danger, but might be necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: C++ Type: usage Issue is a user question
Projects
None yet
Development

No branches or pull requests

5 participants