Skip to content

Commit

Permalink
docs: remove outdated discussion about externally changing module bin…
Browse files Browse the repository at this point in the history
…dings (JuliaLang#53170)

As of Julia 1.9, bindings in modules can be changed directly.

See https://discourse.julialang.org/t/clarify-the-documentation-about-modifying-module-variables/109668/3

(cherry picked from commit 736eeda)
  • Loading branch information
goerz authored and Drvi committed Jun 7, 2024
1 parent 8b55d1c commit b85d575
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions doc/src/manual/variables-and-scoping.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,7 @@ Each module introduces a new global scope, separate from the global scope of all
is no all-encompassing global scope. Modules can introduce variables of other modules into their
scope through the [using or import](@ref modules) statements or through qualified access using the
dot-notation, i.e. each module is a so-called *namespace* as well as a first-class data structure
associating names with values. Note that while variable bindings can be read externally, they can only
be changed within the module to which they belong. As an escape hatch, you can always evaluate code
inside that module to modify a variable; this guarantees, in particular, that module bindings cannot
be modified externally by code that never calls `eval`.

```jldoctest
julia> module A
a = 1 # a global in A's scope
end;
julia> module B
module C
c = 2
end
b = C.c # can access the namespace of a nested global scope
# through a qualified access
import ..A # makes module A available
d = A.a
end;
julia> module D
b = a # errors as D's global scope is separate from A's
end;
ERROR: UndefVarError: `a` not defined
```
associating names with values.

If a top-level expression contains a variable declaration with keyword `local`,
then that variable is not accessible outside that expression.
Expand Down

0 comments on commit b85d575

Please sign in to comment.