Skip to content
Viral B. Shah edited this page Aug 6, 2011 · 1 revision
  1. (Scope extent rule) The following forms introduce new variable scopes: function, -> (i.e. lambda), for loop, while loop, try block, catch block.
  2. (Argument rule) The arguments to a function are local within the function, and cannot be shadowed by global or local declarations within the function.
  3. (Global default rule) A variable that is not assigned, not an argument, and not introduced by a local declaration in any enclosing scope, is global by default.
  4. (Local default rule) Variables introduced as local in a particular scope are inherited by inner scopes by default.
  5. (Global declaration rule) Within a scope, a variable declared with global x refers to a global variable of the enclosing module. This declaration is inherited by inner scopes.
  6. (Local declaration rule) Within a scope, local x introduces a new local, shadowing any variables from enclosing scopes.
  7. (Implicit local rule) If a variable is assigned in a certain scope, not declared global, and not introduced as a local by any enclosing scope, then it is introduced as a new local of its scope.