Question: (* QUESTION 1. Dynamic Scope *) (* Consider the following program: { begin int x = ... int y = ... int z = ...

(* QUESTION 1. Dynamic Scope *)

(* Consider the following program:

{ begin

int x = ...

int y = ...

int z = ...

int f ()

{ int a = ...

int y = ...

int z = ...

...code for f...

}

int g ()

{ int a = ...

int b = ...

int z = ...

...code for g...

}

int h ()

{ int a = ...

int x = ...

int w = ...

...code for h...

}

...code for main (outer) block...

}

Assume dynamic scope. Given the following calling

sequences, what variables are visible during execution of the

last function call in each sequence? Include with each

visible variable the name of the block where it is declared

(main, f, g, or h). Draw the full activation stack. In each

activation record, include the local variables and the

control link only.

(a) main calls h; h calls f.

(b) main calls f; f calls h; h calls g.

(c) main calls h; h calls g; g calls f.

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 Databases Questions!