julia icon indicating copy to clipboard operation
julia copied to clipboard

Correctly mark all symbols as `public` or not

Open LilithHafner opened this issue 2 years ago • 25 comments

#50105 added a preliminary list of symbols to be marked as public from Base. We should finalize that list for Base, stdlibs, and submodules before 1.11.

### Tasks
- [x] Base
- [ ] Submodules of Base
- [ ] Stdlibs
- [ ] A final review to make sure we're not marking anything as pubic that we don't want to

LilithHafner avatar Sep 15 '23 13:09 LilithHafner

is this issue solved or can i help?

adityam003 avatar Oct 01 '23 06:10 adityam003

This issue is very much not solved, and we would appreciate your help!

Any symbol that is mentioned in the manual in Julia 1.9 or 1.10 and is not exported should be marked as public with public that_symbol. If you want to help, you can look through submodules of Base and/or standard libraries to find these symbols and mark them as public. Ideally, you would find many symbols and mark them all as public in a single PR so discussion can be more effective. In some cases it might not be clear whether or not a symbol is supposed to be public, feel free to take a guess and mention that you are unsure and other folks can weigh in with their opinions.

LilithHafner avatar Oct 01 '23 12:10 LilithHafner

Can you explain me bit more specifically about how should i approach this.

adityam003 avatar Oct 02 '23 06:10 adityam003

You could install Julia 1.11 (download the nightly or build from source) and then run names(Base.Iterators, all=true) or using Random; names(Random, all = true) or the same for any module. That will give a list of symbols. If you then run names(Base.iterators), that will give a list of public symbols. If you find things in the longer list that are explicitly mentioned the online manual, then they should probably also be in the shorter list and you can open a PR to mark them as public.

LilithHafner avatar Oct 02 '23 14:10 LilithHafner

so should i download all the dependencies for building julia or can i just clone it in my local machine and run for this task

adityam003 avatar Oct 02 '23 14:10 adityam003

Ideally, this should work:

$ git clone https://github.com/JuliaLang/julia
$ cd julia
$ make
... wait a long time ...
$ ./julia

If you try this and get an error and you are running on a mainstream OS, let us know, because that's probably a bug on our end.

LilithHafner avatar Oct 02 '23 15:10 LilithHafner

make doesnt work for windows

adityam003 avatar Oct 02 '23 16:10 adityam003

Ah, right. Windows. The steps for building from source are a bit more complicated: https://docs.julialang.org/en/v1/devdocs/build/windows/#Source-distribution

You don't have to build from source to contribute, but it can be very helpful in testing your PRs.

LilithHafner avatar Oct 02 '23 17:10 LilithHafner

Base.include is documented in the manual and referred to from other help sections, so it seems like it's part of the public interface. The REPL help, however, says: "The following bindings may be internal; [...]"

nsajko avatar Oct 19 '23 15:10 nsajko

How is this possible lol

julia> Base.include === include
false

LilithHafner avatar Oct 19 '23 17:10 LilithHafner

Every module has an include function that is private to that module

vtjnash avatar Oct 19 '23 17:10 vtjnash

Base.include and Base.MainInclude.include are two different functions, both documented. The latter is the one exported from Base:

julia> Base.MainInclude.include === include === Main.include
true

nsajko avatar Oct 19 '23 18:10 nsajko

What about Stdlibs?

Take SHA.jl as an example. All symbols list in docs are exported, so there is nothing to do, right?

docs HTML: https://docs.julialang.org/en/v1/stdlib/SHA/ docs md: https://github.com/JuliaCrypto/SHA.jl/blob/88e1c83c32790c1cfbd0d13cc71c7db32bd6a573/docs/src/index.md?plain=1#L61 export: https://github.com/JuliaCrypto/SHA.jl/blob/88e1c83c32790c1cfbd0d13cc71c7db32bd6a573/src/SHA.jl#L36-L49

Do we need to change export to public or something else?

inkydragon avatar Nov 19 '23 05:11 inkydragon

Do we need to change export to public or something else?

No need to do that, AFAIK: either one of public or export denote public API, the difference is just that public doesn't pollute namespaces (when imported with using instead of import).

nsajko avatar Nov 19 '23 05:11 nsajko

Hello,

Is this issue solved, else I'd love to contribute. It is my first time contributing to open source, so any tips on how to go about it would help a ton.

Thanks

ShrutiRDalvi avatar Jan 12 '24 09:01 ShrutiRDalvi

For the Tar stdlib, there are https://github.com/JuliaIO/Tar.jl/pull/174 and https://github.com/JuliaIO/Tar.jl/pull/175.

lgoettgens avatar Feb 07 '24 08:02 lgoettgens

I'm looking at candidates in Base.Broadcast. Where should the corresponding public statement go? To broadcast.jl (following export?), to public.jl or elsewhere?

matthias314 avatar Apr 12 '24 00:04 matthias314

Xref #53900 for Base.Iterators.

For Base.Broadcast I believe they would go in https://github.com/JuliaLang/julia/blob/master/base/broadcast.jl

mcabbott avatar Apr 12 '24 00:04 mcabbott

OK, the PR for Base.Broadcast is #54060.

matthias314 avatar Apr 12 '24 00:04 matthias314

I don't think this has to be on the milestone since adding a public can always be done in a later release.

KristofferC avatar Apr 23 '24 08:04 KristofferC

It's just that users will start getting "this symbol may be internal" warnings for docstrings of nonpublic symbols in 1.11

LilithHafner avatar Apr 23 '24 17:04 LilithHafner

I don't think this has to be on the milestone since adding a public can always be done in a later release.

I'm not a fan of this, because that means a symbol could be public on 1.10 (because it's in the manual), private on 1.11 (because it's not declared with public), and then public again on 1.12 (because it gets declared with public later on). We should be encouraging less usage of private symbols, not more. Anything on 1.11 that is not declared with export or public is officially private.

In fact, making a public symbol private is a breaking change according to SemVer, so this issue should block release of 1.11. (EDIT: I guess that's probably not quite true in Julia, since making a symbol private in Julia does not break any code.)

CameronBieganek avatar May 22 '24 15:05 CameronBieganek

There are some modules that are declared public:

public
# Modules
    Checked,
    Filesystem,
    Order,
    Sort,

I think the Iterators and ScopedValues modules should probably be added to that list. (I think ScopedValues is in the 1.11 release, right?)

CameronBieganek avatar May 22 '24 15:05 CameronBieganek

Iterators

Iterators is already public by way of export

julia> Iterators
Base.Iterators

julia> Base.ispublic(Base, :Iterators)
true

julia> VERSION
v"1.11.0-beta1"

ScopedValues

Either that module should be public or Base should re-publicize its exports. I prefer the former, slightly.

LilithHafner avatar May 22 '24 16:05 LilithHafner

Iterators is already public by way of export

Ah, I see, thanks.

ScopedValues

Either that module should be public or Base should re-publicize its exports. I prefer the former, slightly.

Yeah, I think the ScopedValues module should be made "public" (as opposed to public) by being added to the export list for Base (along with Iterators, Threads, Sys, etc).

CameronBieganek avatar May 22 '24 18:05 CameronBieganek

Base.literal_pow should also be marked as public: see https://github.com/JuliaLang/julia/issues/55194 for details (that issue is closed while not a full duplicate imo).

aplavin avatar Jul 21 '24 19:07 aplavin