6.4 Static Scoping
Static scoping means that the declaration to which a reference is bound can be determined before run-time (i.e., statically) by examining the text of the program. Static scoping was introduced in ALGOL 60 and has been widely adopted by most programming languages. The most common instance of static scoping is lexical scoping, in which the scope of variable declaration is based on the program’s lexical layout. Lexical scoping and static scoping are not synonymous (Table 6.2). Examining the lexical layout of a program is one way to determine the scope of a declaration before run-time, but other strategies are also possible. In lexically scoped languages, the scope of a variable reference is the code constituting its static ancestors. ...
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