-
-
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
Syntax proposal: Accessing non-exported names #40127
Comments
I am not sure we really need syntax for this. Currently the convention is that internal functions have names which start with an underscore to signify that they are not part of the public API, which seems to work pretty well. We also can not use |
Using an underscore to signal non-public names is, as you said, just a convention and many packages don't follow that convention (I'm speaking more from the client code writer's point of view). As for the operator, I don't care what operator would be actually used for this. I just want a clear signal to the client code writers. Maybe |
It is a pretty strong convention and also used by Base, what packages did you have in mind that don't follow this convention? Also note that a function not being exported does not necessarily mean that it is not part of the public API, i.e. I did notice however, that the underscore convention is not really emphasized in the manual. I think it would be good to add this here: https://docs.julialang.org/en/v1/manual/style-guide/#Use-naming-conventions-consistent-with-Julia-base/ |
Maybe the underscore convention is good enough, as it is in Python. By the way, in my opinion, |
Anyway, I'm closing this now. If the underscore convention is strong enough and widely used, I'm fine with that. Thanks for the replies. |
Julia has very little control over name visibility -- you can access any names from a module whether they are exported or not. I think it's good because it gives people more control over how to use other modules. But it'd be perfect if the client code could get more hints when it accesses non-exported names.
In Common Lisp, you can access exported symbols by
foo
(whenfoo
isuse
d) ormypkg:foo
. But when you want to access non-exported symbols, it must always be done via double-colon (vs single one):mypkg::foo
. It gives the client code a good warning, "You're now depending on the implementation detail. You're free to use it now but it may not be available in the next version of the package. Use at your own risk".Can we enforce something similar in Julia? For example, with code like this:
The client code of this module would be able to do
MyModule.greet("Jane")
orgreet("Jane")
(whenusing
d). But to accesscall
, it must always doMyModule..call("Jane")
(with double-period). The syntax could be something else. I just want the client code writers to receive a good hint about what they are doing.The text was updated successfully, but these errors were encountered: