Love it or hate it, one just has to accept it at this point — it can’t be changed in Julia 1.x for non-interactive code without breaking backwards compatibility, which we won’t do.
Background: when Julia 1.0 was released, many people started complaining about the new scoping rules and there was extensive discussion. See e.g.
- Global variable scope rules lead to unintuitive behavior at the REPL/notebook · Issue #28789 · JuliaLang/julia · GitHub and RFC: bring back v0.6 scope rules in the REPL by JeffBezanson · Pull Request #33864 · JuliaLang/julia · GitHub
- Many, many discussions on discourse, e.g. REPL and for loops (scope behavior change) … Remove the soft scope altogether and make it global … Explain scoping confusion to a programming beginner …
However, putting aside any discussion of the merits of one rule or another, the scoping rules could not be changed in files/modules after Julia 1.0 was released because of the backward-compatibility guarantee (until Julia 2.0 in the distant future). See also PSA: Julia is not at that stage of development anymore. As a compromise solution, after much debate, the behavior was changed in the interactive REPL (following an earlier experiment in IJulia) — and other interactive environments (vsCode and hopefully soon Juno) are now following suit — with a warning for code in files (scripts and modules).
At this point, there is no point in arguing about it — there is no argument you could possibly make that has not already been made dozens of times.