Question: In languages as Pascal that use static scope rules and allow recursive subprogram calls, it is sometimes difficult to relate a nonlocal reference in one

 In languages as Pascal that use static scope rules and allow

In languages as Pascal that use static scope rules and allow recursive subprogram calls, it is sometimes difficult to relate a nonlocal reference in one subprogram to a particular variable in another subprogram if there are several recursive activations of that second subprogram in existence. For example, suppose A, B, c, and D are the subprograms of program main and A is called by main. Suppose A calls B, B calls A recursively, A calls c and then c calls a- (4 pts) If D makes a nonlocal reference to variable x in A, then which x is visible in D -that is in the first Activation Record (AR) of a or the second? (6 pts) With the calling of nonlocal referencing patterns assumed here, only four different static nestings of the definitions of A, the four static nestings. (7 pts) For each of the four static nestings, draw the activation record at the time that x is referenced in D, showing the AR forA, B, c, and D and the static and dynamic chains. For each case, give the run-time representation of x as pair (n m) and explain which data object x is the nonlocal reference to x in D must retrieve given the run-time structure. Assume static chain pointer implementation of nonlocal referencing b- B, c, and D are possible. Draw c

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!