Aktuelle Änderungen Printable View Änderungen Bearbeiten
ScopeClear TrailThe term lexical is derived from the fact that the behavior of these variables can be determined simply by reading the text of the source code, and is not affected by what happens during the program's execution.
Dynamic scope happens when you basically mix the concept of global parameters and local let variables.[1]
In a dynamically scoped language, e.g. most versions of Lisp, an identifier can be referred to, not only in the block where it is declared, but also in any function or procedure called from within that block, even if the called procedure is declared outside the block.[2]
Dynamic scoping is extremely simple to implement. To find an identifier's value, the program traverses the runtime stack, checking each activation record (each function's stack frame) for a value for the identifier.[3]
dynamic scope dictates that the interpreter search in the frames of functions that called the function in which the variable reference appears.[4]
In a lexically scoped language, the scope of an identifier is fixed at compile-time to be the smallest block (begin/end or function/procedure body) containing the identifier's declaration. This means that an identifier declared in some block is only accessible within that block and from procedures declared within it. [5]
With static scoping, a variable always refers to its nearest enclosing binding. This is a property of the program text and unrelated to the runtime call stack.[6]