Skip to content

Commit

Permalink
doc: correct apparent inconsistency in describing redefining globals (J…
Browse files Browse the repository at this point in the history
…uliaLang#47083)

The documentation stated that built-in constants and functions could
both be redefined and _not_ be redefined, while it seemed to more
nearly mean shadowed in the former case.

Co-authored-by: Jameson Nash <[email protected]>
  • Loading branch information
Preve92 and vtjnash authored Nov 3, 2023
1 parent 1a4a3a0 commit 9c63250
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions doc/src/manual/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ name `δ` can be entered by typing `\delta`-*tab*, or even `α̂⁽²⁾` by `\a
that you don't know how to type, the REPL help will tell you: just type `?` and
then paste the symbol.)

Julia will even let you redefine built-in constants and functions if needed (although
this is not recommended to avoid potential confusions):
Julia will even let you shadow existing exported constants and functions with local ones
(although this is not recommended to avoid potential confusions):

```jldoctest
```jldoctest; filter = r"with \d+ methods"
julia> pi = 3
3
Expand All @@ -71,6 +71,12 @@ julia> pi
julia> sqrt = 4
4
julia> length() = 5
length (generic function with 1 method)
julia> Base.length
length (generic function with 79 methods)
```

However, if you try to redefine a built-in constant or function already in use, Julia will give
Expand Down

0 comments on commit 9c63250

Please sign in to comment.