Example .
. Output under lexical scoping
0.250 0.250
0.250 0.250
. Output under dynamic scoping
0.250 0.125
0.250 0.125
The outputs under the lexical and the dynamic scoping are as shown. Under dynamic scoping, when show is called in the main program, 0.250 is written because the variable r local to the main program is used. However, when show is called from within small, 0.125 is written because the variable r local to small is used.
|