Don't miss an insight. Subscribe to Techopedia for free.


Lexical Scoping

What Does Lexical Scoping Mean?

Lexical scoping is setting the scope of a functionality of a certain variable using a method, which facilitates calling the variable from the code block in which it was defined. It is only during the compilation phase in which the scope is determined. A private variable is a variable declared in a manner compatible with this definition.


This term is also known as static scoping.

Techopedia Explains Lexical Scoping

Lexical scoping allows variables to be declared within a specific scope and it is only accessible within that region. Lexical scoping allows for lexical closures, but the absence of closures still ensures that the scope allows the function to be re-entrant. However, the absence of closures gives rise to dynamic scoping.

Lexical scoping is standardized in all algorithmic languages (ALGOL), such as Ada, Pascal, and Modula2. Additionally, it is used in modern functional languages like ML and Haskel.


Related Terms