Grouping Symbols into Scopes
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access