IT lexicon › Programming › Lexical scoping

Lexical scoping

Programming På svenska → Updated: 2026-11-12

Variable-lookup model in which names are resolved according to the source code's textual structure, not runtime execution order.

Lexical scoping, also called static scoping, is the modern standard. A variable name binds to its nearest enclosing declaration in code, regardless of calling context. This makes code highly readable and predictable—a developer can determine what a variable refers to by reading source alone. Algol 60 codified this concept, in contrast to older languages' often implicit dynamic scoping. All modern languages prefer lexical scoping, though some Lisp dialects still offer dynamic scoping for special cases.

← Back to the lexicon