after reading few post in this forum on this topic i had better understanding on static and dynamic scoping.
However, i have encountered a problem from internet and seems to face issues to get around with that.
The code is as follows:
x : integer –– global
procedure set x(n : integer)
x := n
procedure print x
write integer(x)
procedure first
set x(1)
print x
procedure second
x : integer
set x(2)
print x
set x(0)
first()
print x
second()
print x
It’s not that easy to predict what will happen in some imaginary language after launching a pseudocode but expected result will be:
P.S. those are not called static/dynamic. Those are
global/local. At least in those languages I know.