-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add public keyword #50105
Add public keyword #50105
Changes from 1 commit
5b3d8c1
665855e
52f519e
03f9e02
7eb64a2
c7192ea
ec3b2f3
804f5ef
7d404f0
4dc10c4
5fd1f64
b85ae46
acc928a
a5162c2
aacc187
145ad7f
aea3d22
f7d57ba
34844bb
8241760
920244a
9e61f96
f75cb68
db7ba05
7dbdd5e
ac11ea4
bd0ee87
1dc9652
17b8834
6e2ddec
1000988
c5955c0
5ed2c7d
5da758e
de8be2b
d75725b
05352df
4b04f31
051f824
8a56ab4
6e2d809
69cf8d4
9d74beb
4b18e1d
4ba71ab
ce3a798
ca8eb44
6d1e2c7
2678523
528469b
082fb86
3d09dae
12bab72
0112e2c
66427c6
067d69c
b688b60
6ce6fdb
e57c63f
1a6e3dc
ebcdf24
d4418fe
c4924c9
5835699
153b538
158d59f
41f3729
fd5fb90
ea7a141
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,26 +73,28 @@ function fullname(m::Module) | |
end | ||
|
||
""" | ||
names(x::Module; all::Bool = false, imported::Bool = false) | ||
names(x::Module; qualified::Bool=true, all::Bool = false, imported::Bool = false) | ||
|
||
Get an array of the names exported by a `Module`, excluding deprecated names. | ||
If `all` is true, then the list also includes non-exported names defined in the module, | ||
Get an array of the public names of `Module`, excluding deprecated names. | ||
|
||
If `qualified` is false, then return only exported names, not public but unexported names. | ||
If `all` is true, then the list also includes private names defined in the module, | ||
deprecated names, and compiler-generated names. | ||
If `imported` is true, then names explicitly imported from other modules | ||
are also included. | ||
|
||
As a special case, all names defined in `Main` are considered \"exported\", | ||
since it is not idiomatic to explicitly export names from `Main`. | ||
As a special case, all names defined in `Main` are considered \"public\", | ||
since it is not idiomatic to mark names from `Main` as public. | ||
|
||
See also: [`@locals`](@ref Base.@locals), [`@__MODULE__`](@ref). | ||
""" | ||
names(m::Module; all::Bool = false, imported::Bool = false, scoped::Bool = true) = | ||
sort!(unsorted_names(m; all, imported, scoped)) | ||
unsorted_names(m::Module; all::Bool = false, imported::Bool = false, scoped::Bool = true) = | ||
ccall(:jl_module_names, Array{Symbol,1}, (Any, Cint, Cint, Cint), m, all, imported, scoped) | ||
names(m::Module; qualified::Bool = true, all::Bool = false, imported::Bool = false) = | ||
sort!(unsorted_names(m; qualified, all, imported)) | ||
unsorted_names(m::Module; qualified::Bool = true, all::Bool = false, imported::Bool = false) = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we throw if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "If qualified is false, then return only exported names, not public but unexported names." only exported names that are unexported names? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a possible solution:
This docstring should fully describe the proposed behavior and so is ready for review. If the docstring doesn't make it completely clear what I mean, then it's not a good enough docstring. I'm holding back on implementing this until I know what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edited to explain tbh I'm not entirely sure what the deal with compiler-generated names is. They typically start with an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think calling this "hidden" is a good idea, if we want to expose this at all. It just seems like another easy-to-confuse thing, thinking of "object hiding" in other languages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've never heard of "object hiding", would you provide a link please? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apologies for not using the exact terminology. I was indeed referring to "data hiding" or "information hiding". I used "object hiding" here because in Julia, this has the effect of generally hiding any object. The semantic meaning is the same. It's precisely this closeness to the existing concept that's the reason for my objection. |
||
ccall(:jl_module_names, Array{Symbol,1}, (Any, Cint, Cint, Cint), m, qualified, all, imported) | ||
|
||
isexported(m::Module, s::Symbol) = ccall(:jl_module_exports_p, Cint, (Any, Any), m, s) != 0 | ||
isinternal(m::Module, s::Symbol) = !isexported(m, s) && ccall(:jl_module_scoped_exports_p, Cint, (Any, Any), m, s) == 0 | ||
isinternal(m::Module, s::Symbol) = ccall(:jl_module_public_p, Cint, (Any, Any), m, s) == 0 | ||
isdeprecated(m::Module, s::Symbol) = ccall(:jl_is_binding_deprecated, Cint, (Any, Any), m, s) != 0 | ||
isbindingresolved(m::Module, var::Symbol) = ccall(:jl_binding_resolved_p, Cint, (Any, Any), m, var) != 0 | ||
|
||
|
LilithHafner marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we decide to try making new keywords here correspond somehow to the flags in
jl_binding_t
so that the filtering behavior ofnames()
is much easier to specify? I forgot which conclusion we came to!