From 88e0e86fdf7bcf2f61478ca326b3d443e4beef11 Mon Sep 17 00:00:00 2001 From: Helios De Rosario Date: Wed, 7 Apr 2021 12:46:52 +0200 Subject: [PATCH] Clarify explanation of nested local scope Based on my suggestion in #40238 (but with clearer wording I hope) --- doc/src/manual/variables-and-scoping.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/src/manual/variables-and-scoping.md b/doc/src/manual/variables-and-scoping.md index 906a6c6d06b43..28a143379f704 100644 --- a/doc/src/manual/variables-and-scoping.md +++ b/doc/src/manual/variables-and-scoping.md @@ -104,7 +104,9 @@ Note that the interactive prompt (aka REPL) is in the global scope of the module ## Local Scope A new local scope is introduced by most code blocks (see above [table](@ref man-scope-table) for a -complete list). Some programming languages require explicitly declaring new variables before using +complete list). If such a block is inside another local scope, this will be a "nested" local scope +that contains existing locals — even if the code where they are defined is written after the nested block. +Some programming languages require explicitly declaring new variables before using them. Explicit declaration works in Julia too: in any local scope, writing `local x` declares a new local variable in that scope, regardless of whether there is already a variable named `x` in an outer scope or not. Declaring each new local like this is somewhat verbose and tedious, however, so