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

Document guidance for changes in unexported functions #12696

Closed
wants to merge 1 commit into from

Conversation

rsrock
Copy link
Member

@rsrock rsrock commented Aug 19, 2015

Fixes #12647

Explains the public nature of Julia names, and how to obtain some measure of
privacy when needed. Also provides guidance for breaking changes in public APIs,
unexported names, and private (underscore) names.

[ci skip]

@rsrock
Copy link
Member Author

rsrock commented Aug 19, 2015

The goal here is to explain how things currently work (not what we want to have!), and to provide some guidance. A few things to consider:

  1. Is this accurate?

  2. In the right place?

and 3) Is the guidance appropriate / sufficiently complete?

variables, functions, types, and the fields of composite types are publicly
accessible. Julia does not have corresponding "private" versions of these
items that are inaccessible from outside the module. However, a common
Julia convention is that names prefixed with an underscore (e.g.,
Copy link
Member

Choose a reason for hiding this comment

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

Is it really true that this is a "common Julia convention"?

Copy link
Member

Choose a reason for hiding this comment

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

No. We tried it out and it's too annoying.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not at all wedded to this language. Perhaps just "However, names prefixed with an underscore are private implementation details."

However, I just grepped base for " _" and found ~600 lines that look like names (primarily functions) intended to be private. For example, osutils.jl:12 has a function _os_test() that looks like it's used only in the macros just below, and it seems like it's intended only for internal consumption. So it does seem to have crept in there.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we were trying it out for a while and there's still a lot of these names hanging around.

@kshyatt kshyatt added the docs This change adds or pertains to documentation label Aug 19, 2015
@tknopp
Copy link
Contributor

tknopp commented Aug 19, 2015

I don't think its good to document this. While this is how it currently works, it strikes me as suboptimal and putting it into the documentation kind of says: We are happy about this.

@rsrock
Copy link
Member Author

rsrock commented Aug 19, 2015

No, I don't see that we have to be happy about it, even if it's documented. I think writing this down helps to clarify what we don't like ("Unexported and undocumented"-- ugh). The documentation can change with the fixes.

@ScottPJones
Copy link
Contributor

Maybe be explicit in the documentation that we are not happy with it, and it might change in the (hopefully near) future?

@aviks
Copy link
Member

aviks commented Aug 19, 2015

Maybe be explicit in the documentation that we are not happy with it, and it might change in the (hopefully near) future?

Please, no. Language documentation should have an objective voice. Otherwise its just chaos.

@rsrock
Copy link
Member Author

rsrock commented Aug 19, 2015

Yeah, I considered that, but came to the same conclusion as @aviks

@ScottPJones
Copy link
Contributor

OK, good point, @aviks

Fixes JuliaLang#12647

Explains the public nature of Julia names.  Also provides guidance for
breaking changes in public APIs vs. unexported names.

[ci skip]
@rsrock rsrock force-pushed the rsr/doc-public-private branch from 22d62c3 to 88c7771 Compare August 19, 2015 23:43
may change at any time, with or without warning. Therefore, usage outside of
their parent module carries certain risks. We recommend that all such usage is
clearly commented in code. At the same time, unexported but externally "popular"
names should be considered for inclusion in the exported public API.
Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps this should be strengthened to include @tkelman point, that authors should make a good-faith effort to avoid unnecessary code churn.

@vtjnash
Copy link
Member

vtjnash commented Jun 26, 2019

Closing as #12647 is closed now and this is pretty old now.

@vtjnash vtjnash closed this Jun 26, 2019
@rsrock
Copy link
Member Author

rsrock commented Jun 26, 2019

👍 I don't even like this anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some sort of policy to regarding unexported functions in Base?
9 participants