Consider the following pseudocode program Suppose dynamic sc
Consider the following pseudo-code program: Suppose dynamic scoping with shallow binding is used by the interpreter to execute this code. What is the value printed by the program? Suppose dynamic scoping with deep binding is used by the interpreter to execute this code. What is the value printed? Suppose static scoping is used. What is the value printed by the program?
Solution
a.With Shallow binding , It finds the nearest variable that corresponds to the name.So the value printed would be 1.
b.With Deep binding , the x is the global x so it writes 2.
c.With static scoping , it will be 0.
Let me know if you have any doubts.
Thanks.
