December 2009
Intermediate to advanced
380 pages
9h 2m
English
A scope is a code region with a well-defined boundary that groups symbol definitions (in a dictionary associated with that code region). For example, class scopes group members; function scopes group parameters and local variables. Scope boundaries usually coincide with begin and end tokens such as curly braces (sort of like the “hello” and “goodbye” of a phone conversation). We call this lexical scoping because the extent of a scope is lexically delimited. Perhaps a better term is static scoping because we can track scopes just by looking at the source code; that is, without executing it. Here’s a list of scope characteristics that often differ between languages:
Static vs. dynamic scoping: Most languages have static ...