Question: Consider the following program: In each case YOU MUST SHOW ALL OF YOUR WORK proc main int x, z; proc A: int a; proc B;
Consider the following program:
In each case YOU MUST SHOW ALL OF YOUR WORK
proc main
int x, z;
proc A:
int a;
proc B;
int x, a;
{ x := 2; a:= 8; call C; print x; } (end B)
proc C;
int z;
{ x := 4; z := 7; print a; } (end C)
{ x := 3; z := 5; a:= 6; call B; print x; } (end A)
proc D;
int x, b;
proc E;
int x, z;
{ x := 5; z:= 11; call F; print x; } (end E)
proc F;
proc G;
{ print z; x:= 8; call A; print x; } (end G)
{ print x; call G; x:=7; } (end F)
{ x := 12; call E; print x; } (end D)
{ x:= 1; z := 9; call D; print x; } (end main)
(a) (6pts) What is the program output assuming static scoping rules are employed?
(b) (6pts) What is the corresponding output when dynamic scoping rules are employed?
(c) (5pts) List all of the units (proc's) that proc C can call (assuming static scoping).
(d) (4pts) Specify the referencing environment of proc F (assuming static scoping)
That is, list the variables that are visible to proc F
(e) (4pts) Specify the referencing environment of proc F (assuming dynamic scoping)
That is, list the variables that are visible to proc F
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
