Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRFC: Exports on individual items (pub and priv) #1893
Comments
This comment has been minimized.
This comment has been minimized.
|
I'm in favour of this. Scrolling back and forth to the export list at the top of the file to keep things consistent is painful and error-prone. Also, this might nicely generalize glob exports -- |
This comment has been minimized.
This comment has been minimized.
|
+1 from me. I would also like it if things were private by default in all cases, just for simplicity. (As opposed to "if there are no pub declarations, then everything is pub") |
This comment has been minimized.
This comment has been minimized.
|
Also, I think we should use the same convention for classes. |
This comment has been minimized.
This comment has been minimized.
|
@marijnh It does generalize export globs, yes. That's more or less how I've modified the resolve pass to treat export globs anyways. Merged the glob-specifying AST nodes and just treats an export glob as "an import of the same kind that happens to re-export its target". I'm not completely in favour of this, but partly. It's similar to how I did things at first; I changed to the current system for these reasons:
I realize these are in direct tension with the desire to avoid flipping up-and-down between definitions and export lists though. So I'm just .. curious if there's some way to relieve that tension. Some languages "solve" this by using sectioning directives within definition scopes. That is, the way C++ members are organized into any number of As an aside, I think if we make this change we should bundle it with two other changes:
|
This comment has been minimized.
This comment has been minimized.
|
Having all the exported symbols live in one place is nice, but the problem is that only the identifiers, not the signatures, live there. So in practice one ends up scrolling down to find the definition anyway. I think I'm ok with crate-local visibility being the default.
|
This comment has been minimized.
This comment has been minimized.
|
Yeah. What you say wrt. signatures is true. I find the export-lists only moderately helpful as a synopsis. They're no function prototypes. I'm certainly willing to experiment with this and see how it looks. (Resolve is due for a reorganization anyways, I think. But maybe that is orthogonal to this.) |
This comment has been minimized.
This comment has been minimized.
|
How does this work with enum variants? Are they also crate-visible by default and require |
This comment has been minimized.
This comment has been minimized.
|
Maybe have them default to the visibility of their declaring enum, with explicit overriding permitted? We'd need the keyword for crate-visible in that case, as you say (I realize this is slightly widening the scope of this RFC), but perhaps |
This comment has been minimized.
This comment has been minimized.
|
At meeting, had consensus to implement this (pub, priv, crate) access-control on items, and turn export into import + access control. |
brson
referenced this issue
Mar 12, 2012
Closed
Dinstinguish between within-crate export, and crate-external export #864
ghost
assigned
marijnh
Apr 13, 2012
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
See also https://gist.github.com/2481106 |
marijnh
added a commit
that referenced
this issue
May 8, 2012
marijnh
added a commit
that referenced
this issue
May 8, 2012
nikomatsakis
referenced this issue
May 9, 2012
Closed
Rename `extensions` to `methods` in libs #2371
This comment has been minimized.
This comment has been minimized.
|
punting to 0.4 |
This was referenced Jul 18, 2012
eholk
referenced this issue
Jul 18, 2012
Closed
Add a lint pass to warn when things are exported but not documented #2953
nikomatsakis
referenced this issue
Aug 31, 2012
Closed
RFC: Unify pub for classes and pub for export #2300
ghost
assigned
pcwalton
Aug 31, 2012
This comment has been minimized.
This comment has been minimized.
|
This is working on incoming, except for cross-crate methods. Needs a snapshot to get rid of the old syntax. |
This comment has been minimized.
This comment has been minimized.
|
Closing; any remaining issues should be followups. |
pcwalton commentedFeb 23, 2012
Instead of
exportlists, we could have exports on individual items.So, instead of:
We would have:
And instead of:
We would have:
(Here I changed
exporttopubto better match classes and to avoid exceeding the 5-character limit, but I'm ok either way.)This change would help avoid the pain of managing export lists and should make libraries easier to write. Often people look at the definitions of items and want to know then and there whether the item is public or not.