Question: Problem 3 : Deep and Shallow Binding Consider the following pseudocode, assuming dynamic scoping rules: procedure main ( ) { x:int : = 2 y:

Problem 3: Deep and Shallow Binding
Consider the following pseudocode, assuming dynamic scoping rules:
procedure main(){
x:int :=2
y: int :=4
procedure increment(n:int){
if n >0{
x}:=x+1
y}:=y+
increment(n -1)
}
}
procedure decrement(n:int){
if n >0{
x := x -5
y := y -2
decrement(n -1)
}
}
procedure two(){
y:int :=3
one(decrement, increment, 2)
}
procedure one(11:procedure, f2:procedure, m:int){
x:int :=10
f1(m)
f2(m)
}
two()
print(x)
print(y)
}
If the language uses deep binding, what will the output be? Explain your answer.
If the language uses shallow binding, what will the output be? Explain your answer.
Problem 3 : Deep and Shallow Binding Consider the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!