-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Should the returned value of a public function applied to public types be public #55280
Comments
Not necessarily. I know some disagree, but I'm not sure why. Sometimes it makes sense to return an opaque value, meant to be passed to other parts of the API of the same package. |
I agree with @nsajko here. Consider the pattern
and
as an example maybe particularly common in the Julia ecosystem, I'm imagining
|
It's possible to have no outer constructors struct Internal
x::Int
global _Internal
_Internal(x) = new(x)
end
make_a_thing(x::Int) = _Internal(x) |
alg = hybrid_algorithm_smart_solver(input)
params = solve!(alg) is a good example.
I think we can say this is fine: the type is public, its constructor isn't public but its As a user I don't like to have any objects in my workspace that are undocumented or nonpublic. |
It doesn't work like that. A name is either public or it's not. |
The name is public, but the documentation says its public API is only |
IMO that's too much to ask of package authors. |
With getfield, a Module, and a Symbol (all public objects), the program could get to anything as a return value, so it is not trivially the case that anything accessed via public functions is public. Perhaps though that anything returned is likely allowed as being public as an argument, but not as the function argument? |
Hmm, rolling this over in my mind isn't this a rather fundamental consequence of choosing to make publicity be with respect too names rather than methods? |
If not public, it would be nice to always have a docstring that tells you what you can do with it. |
Should the returned value of a public function applied to public types be public? I think yes, but want to hear other folks' opinions before making PRs.
Adapted from @jariji's post in #52725 (comment)
The text was updated successfully, but these errors were encountered: