Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2) Given the following skeleton of an Ada-like program, answer the questions at the top of page 2. procedure Main is Y Integer; procedure Subl

image text in transcribed

2) Given the following skeleton of an Ada-like program, answer the questions at the top of page 2. procedure Main is Y Integer; procedure Subl is X, Z: Integer; procedure Sub2 is X, Y: Integer; procedure Sub3 is Z: Integer begin // point l end; //Sub3 begin end //Sub2 A, Z: Integer; procedure Sub4 is procedure Sub5 is A, X : Integer; begin // point 2 end //Sub5 begin // point 3 end //Sub4 begin // point 4 end; //Subl procedure Sub6 is A, X, Y : Integer; begin // point 5 end //Sub6 begin // point 6 end //Main a. Assuming static scope and shadowing is not available, what variables can be Repeat referenced at point 2? List the variables and where they were declared. for point 4 b. Repeat part a assuming shadowing is available c. Assume Main calls sub6 which calls subl which calls sub4 which calls sub3 There is a reference to Y at point 1 (in Sub2). Assuming static scoping, which Y does this reference or does it cause an error? d. Repeat part c assuming this is a dynamically scoped language instead. 2) Given the following skeleton of an Ada-like program, answer the questions at the top of page 2. procedure Main is Y Integer; procedure Subl is X, Z: Integer; procedure Sub2 is X, Y: Integer; procedure Sub3 is Z: Integer begin // point l end; //Sub3 begin end //Sub2 A, Z: Integer; procedure Sub4 is procedure Sub5 is A, X : Integer; begin // point 2 end //Sub5 begin // point 3 end //Sub4 begin // point 4 end; //Subl procedure Sub6 is A, X, Y : Integer; begin // point 5 end //Sub6 begin // point 6 end //Main a. Assuming static scope and shadowing is not available, what variables can be Repeat referenced at point 2? List the variables and where they were declared. for point 4 b. Repeat part a assuming shadowing is available c. Assume Main calls sub6 which calls subl which calls sub4 which calls sub3 There is a reference to Y at point 1 (in Sub2). Assuming static scoping, which Y does this reference or does it cause an error? d. Repeat part c assuming this is a dynamically scoped language instead

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

What is meant by each: vouching, tracing, and scanning?

Answered: 1 week ago