Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following skeletal Ada program: procedure Main is X: Integer; procedure Sub3; -- This is a declaration of Sub3 -- It allows Sub1 to

image text in transcribedimage text in transcribed

Consider the following skeletal Ada program: procedure Main is X: Integer; procedure Sub3; -- This is a declaration of Sub3 -- It allows Sub1 to call it procedure Sub1 is X : Integer; procedure Sub2 is begin -- of Sub2 end; -- of Sub2 begin -- of Sub1 end; -- of Sub1 procedure Sub3 is begin -- of Sub3 end; -- of Sub3 begin -- of main end; -- of main Assume that the execution of this program is in the following unit order: Main calls Sub1 Sub1 calls Sub2 Sub2 calls Sub3 Assuming static scoping in the following, which declaration of X is the correct one for a refer- ence to X in each of the following subprograms? [3 points] a. Sub1 (which declaration of X does Sub1 refer to?) b. Sub2 (which declaration of X does Sub2 refer to?) C. Sub3 (which declaration of X does Sub3 refer to?) Explain your answers. Repeat the above (a, b, c), but assume dynamic scoping. Consider the following skeletal Ada program: procedure Main is X: Integer; procedure Sub3; -- This is a declaration of Sub3 -- It allows Sub1 to call it procedure Sub1 is X : Integer; procedure Sub2 is begin -- of Sub2 end; -- of Sub2 begin -- of Sub1 end; -- of Sub1 procedure Sub3 is begin -- of Sub3 end; -- of Sub3 begin -- of main end; -- of main Assume that the execution of this program is in the following unit order: Main calls Sub1 Sub1 calls Sub2 Sub2 calls Sub3 Assuming static scoping in the following, which declaration of X is the correct one for a refer- ence to X in each of the following subprograms? [3 points] a. Sub1 (which declaration of X does Sub1 refer to?) b. Sub2 (which declaration of X does Sub2 refer to?) C. Sub3 (which declaration of X does Sub3 refer to?) Explain your answers. Repeat the above (a, b, c), but assume dynamic scoping

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions