lexical scope

lexical scope

(programming)(Or "static scope") When the scope of anidentifier is fixed at compile time to some region in thesource code containing the identifier's declaration. Thismeans that an identifier is only accessible within that region(including procedures declared within it).

This contrasts with dynamic scope where the scope depends onthe nesting of procedure and function calls at run time.

Statically scoped languages differ as to whether the scope islimited to the smallest block (including begin/end blocks)containing the identifier's declaration (e.g. C, Perl) orto whole function and procedure bodies (e.g. ECMAScript), orsome larger unit of code (e.g. ?). The former is known asstatic nested scope.