Dynamic Scoping

scope (programming).
Dynamic variable scoping is when you scope a variable in a programming language by replacing the existing variable of that name with a new variable temporarily, for instance for the duration of a function call. This is an easy way to implement private variables. However the problem is that if one function calls another, the other may accidentally modify the first function's variables when it intended to modify a global variable instead. Therefore over time it is becoming more common for programming languages to implement private variables with lexical variable scoping instead. For example, take this procedure in the Scheme programming language:
  (define foo    (lambda ()      (let* ((x 5)             (gimmex (lambda () x )))        (let* ((x 10))          (gimmex))))) 
gimmex will return 10 in dynamic scoping, and 5 in lexical scoping. In dynamic scoping, gimmex would return 10, because when gimmex was called, x was defined to be 10. gimmex opens the procedure (lambda () x) to where the current environment is. In other words, variables that occur free in a procedure or subroutine would be looked up in the scope where the procedure was called.

 

<< PreviousWord BrowserNext >>
academy award for directing
arsenal ship
guillaume apollinaire
amedeo modigliani
pierre beaumarchais
comparative advantage
jean moulin
colonel bogey march
imre nagy
cop rock
american broadcasting company
cnn
big three
georges pierre seurat
simone signoret
simone de beauvoir
227 bc
cimetire du montparnasse
man ray
north island
mrs. miniver's problem
south island
carrier pigeon
religious prostitution
cher ami
static scoping
academy award for comedy direction
scope (programming)
panthon, paris
irne joliot curie
gabrielle roy
harold robbins
228 bc
federal radio commission
uss housatonic (1861)
css hunley
arthur hailey
the adventures of robin hood (movie)
alexander's ragtime band
girls and boys town
robert bateman
the citadel
trotskyism
prince philip, duke of edinburgh