Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started