Skip to content

Commit 4bc3206

Browse files
authored
Define publicity at a per-binding level, not per-symbol (JuliaLang#57094)
Symbols don't belong to modules and can't be marked public. The statement `public Fix` in Base does not make the symbol `:Fix` public everywhere. My package's `Package.Fix` may still be private. It's bindings that are marked this way: https://github.com/JuliaLang/julia/blob/fa9478b5178052ef00690732fe363601182b6922/src/julia.h#L695-L705
1 parent 2317c23 commit 4bc3206

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

NEWS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Language changes
5656
behavior. Infinite loops that actually do things (e.g. have side effects
5757
or sleep) were never and are still not undefined behavior. ([#52999])
5858

59-
- It is now an error to mark a symbol as both `public` and `export`ed.
59+
- It is now an error to mark a binding as both `public` and `export`ed.
6060
([#53664])
6161

6262
Compiler/Runtime improvements

doc/src/manual/faq.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ On the other hand, language *interoperability* is extremely useful: we want to e
2323
### How does Julia define its public API?
2424

2525
Julia's public [API](https://en.wikipedia.org/wiki/API) is the behavior described in
26-
documentation of public symbols from `Base` and the standard libraries. Functions,
26+
documentation of public bindings from `Base` and the standard libraries. Functions,
2727
types, and constants are not part of the public API if they are not public, even if
2828
they have docstrings or are described in the documentation. Further, only the documented
29-
behavior of public symbols is part of the public API. Undocumented behavior of public
30-
symbols is internal.
29+
behavior of public bindings is part of the public API. Undocumented behavior of public
30+
bindings is internal.
3131

32-
Public symbols are those marked with either `public foo` or `export foo`.
32+
Public bindings are those marked with either `public foo` or `export foo`.
3333

3434
In other words:
3535

36-
- Documented behavior of public symbols is part of the public API.
37-
- Undocumented behavior of public symbols is not part of the public API.
38-
- Documented behavior of private symbols is not part of the public API.
39-
- Undocumented behavior of private symbols is not part of the public API.
36+
- Documented behavior of public bindings is part of the public API.
37+
- Undocumented behavior of public bindings is not part of the public API.
38+
- Documented behavior of private bindings is not part of the public API.
39+
- Undocumented behavior of private bindings is not part of the public API.
4040

41-
You can get a complete list of the public symbols from a module with `names(MyModule)`.
41+
You can get a complete list of the public bindings from a module with `names(MyModule)`.
4242

4343
Package authors are encouraged to define their public API similarly.
4444

@@ -253,21 +253,21 @@ the variables `A` and `x` were distinct bindings referring to the same mutable `
253253
### Can I use `using` or `import` inside a function?
254254

255255
No, you are not allowed to have a `using` or `import` statement inside a function. If you want
256-
to import a module but only use its symbols inside a specific function or set of functions, you
256+
to import a module but only use its bindings inside a specific function or set of functions, you
257257
have two options:
258258

259259
1. Use `import`:
260260

261261
```julia
262262
import Foo
263263
function bar(...)
264-
# ... refer to Foo symbols via Foo.baz ...
264+
# ... refer to Foo bindings via Foo.baz ...
265265
end
266266
```
267267

268268
This loads the module `Foo` and defines a variable `Foo` that refers to the module, but does not
269-
import any of the other symbols from the module into the current namespace. You refer to the
270-
`Foo` symbols by their qualified names `Foo.bar` etc.
269+
import any of the other bindings from the module into the current namespace. You refer to the
270+
`Foo` bindings by their qualified names `Foo.bar` etc.
271271
2. Wrap your function in a module:
272272

273273
```julia
@@ -281,7 +281,7 @@ have two options:
281281
using Bar
282282
```
283283

284-
This imports all the symbols from `Foo`, but only inside the module `Bar`.
284+
This imports all the bindings from `Foo`, but only inside the module `Bar`.
285285

286286
### What does the `...` operator do?
287287

0 commit comments

Comments
 (0)