Consider the following pseudo-code: x : integer; procedure set_x (n: integer) x = n; procedure print_x...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following pseudo-code: x : integer; procedure set_x (n: integer) x = n; procedure print_x -- write_integer (x); else procedure foo (S, P: procedure; n : integer) x : integer; if n in (1,3) global else S (n); if n in (1,2) print_x; set_x (n); P; main program set_x (0); foo (set_x, print_x, 1); print_x; set_x (0); foo (set_x, print_x, 2); print_x; set_x (0); foo (set_x, print_x, 3); print_x; set_x (0); foo (set_x, print_x, 4); print_x; Assume that the language uses dynamic scoping. What does this program print if the language uses shallow binding? Why? What does it print with deep binding? Why? Note: At exactly one point during execution in the deep binding case, the program will attempt to print an uninitialized variable. Simply write a "?" for the value printed at that point. Consider the following pseudo-code: x : integer; procedure set_x (n: integer) x = n; procedure print_x -- write_integer (x); else procedure foo (S, P: procedure; n : integer) x : integer; if n in (1,3) global else S (n); if n in (1,2) print_x; set_x (n); P; main program set_x (0); foo (set_x, print_x, 1); print_x; set_x (0); foo (set_x, print_x, 2); print_x; set_x (0); foo (set_x, print_x, 3); print_x; set_x (0); foo (set_x, print_x, 4); print_x; Assume that the language uses dynamic scoping. What does this program print if the language uses shallow binding? Why? What does it print with deep binding? Why? Note: At exactly one point during execution in the deep binding case, the program will attempt to print an uninitialized variable. Simply write a "?" for the value printed at that point. Consider the following pseudo-code: x : integer; procedure set_x (n: integer) x = n; procedure print_x -- write_integer (x); else procedure foo (S, P: procedure; n : integer) x : integer; if n in (1,3) global else S (n); if n in (1,2) print_x; set_x (n); P; main program set_x (0); foo (set_x, print_x, 1); print_x; set_x (0); foo (set_x, print_x, 2); print_x; set_x (0); foo (set_x, print_x, 3); print_x; set_x (0); foo (set_x, print_x, 4); print_x; Assume that the language uses dynamic scoping. What does this program print if the language uses shallow binding? Why? What does it print with deep binding? Why? Note: At exactly one point during execution in the deep binding case, the program will attempt to print an uninitialized variable. Simply write a "?" for the value printed at that point.
Expert Answer:
Answer rating: 100% (QA)
In the provided pseudocode we have a global variable x and a set of procedures setx printx and foo We need to understand the output of the program assuming dynamic scoping is used as well as the behav... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Muller Manufacturing Co. Ltd. makes a product by way of three consecutive processes. The following data relates to process 2 for the month of May. (i) During May, 1,500 units valued at $226.50 each...
-
A software organization has implemented a deception strategy to detect unauthorized data access attempts. An attacker, believing to have successfully obtained sensitive data, actually accessed a...
-
Find the present values of the following cash flow streams. The appropriate interest rate is 8%. ( Hint: It is fairly easy to work this problem dealing with the individual cash flows. However, if you...
-
If the resultant force acting on the hook is F R = {? 200i + 800j + 150k} lb, determine the magnitude and coordinate direction angles of F. 30 F= 600 ib
-
Initially, the CICA Handbook did not require financial statements to include information about noncash investing and financing activities. The financial statements reported only changes in working...
-
Peter, Paul and Mary have been in partnership for several years sharing profits and losses in the ratio 1 : 2 : 3. Their last statement of financial position is as follows: The partnership had become...
-
El Conquistador, Inc., finances operations with both bonds and stock. Suppose El Conquistador issued \(\$ 500,000\) of 10 -year, \(8 \%\) bonds payable under various market conditions. Match each...
-
Apply the PBA process for service contracts. A government agency completed an acquisition for landscaping services. The primary purpose of the contract was for mowing the grass around major roadways....
-
Lever - Up Hedge Fund ( LUHF ) can borrow 1 million ( euros ) at an annualized rate of 4 . 2 0 % or $ 1 million dollars at an annualized rate of 4 . 5 0 % . LUHF can invest euros in a 9 0 - day...
-
Consider the unadjusted trial balance of Burrows Landscaping at December 31, 2023, and the related month-end adjustment data: The following adjustments need to be made on December 31 before the...
-
Kenji is a freshman in college. She and Elmira have been best friends for the past two years. When Elmira started dating Marat Kenji was happy for her, but also felt left out. Kenji told Elmira and...
-
The assumption that an entity will continue to operate for the foreseeable future is called: A. accrual basis. B. comparability. C. going concern.
-
When, at the end of an accounting period, cash has been paid with respect to an expense, the business should then record: A. an accrued expense, an asset. B. a prepaid expense, an asset. C. an...
-
All of the following are current assets except : A. cash. B. goodwill. C. inventories.
-
Based on the following information for Star Inc., what are the total net adjustments that the company would make to net income in order to derive operating cash flow? A. Add $2 million. B. Add $6...
-
At the beginning of 2009, Florida Road Construction entered into a contract to build a road for the government. Construction will take four years. The following information as of 31 December 2009 is...
-
15. The decreasing order of acidity of following phenol derivatives is OH OH OCH3 (P) (a) P> Q> R>S (2) OCH3 OCH3 (R) (b) S>R>Q>P (S) (c) S>R>P>Q (d) Q> S>R>P
-
Write a paper by answer the following question: Should Recycling Be Mandatory?
-
Suppose that every monitor has a separate mutual exclusion lock, so that different threads can run in different monitors concurrently, and that we want to release exclusion on both inner and outer...
-
Explain how to obtain the effect of Fortran 90s allocate statement for one-dimensional arrays using pointers in C. You will probably find that your solution does not generalize to multidimensional...
-
We noted in Section 13.3.2 that several processors, including the ARM, MIPS, and Power, provide an alternative to compare_and_swap (CAS) known as load_linked/store_conditional (LL/SC). A load_linked...
-
When there is a concentration gradient in the system, show that the potential gradient is composed of two terms, (i) an Ohm's-law contribution and (ii) a diffusional contribution. State the equation...
-
Copper is deposited at a cathode from solution with a bulk concentration of \(0.5 \mathrm{M}\) at the rate of \(3.0 \mathrm{~g} / \mathrm{m}^{2} \cdot \mathrm{s}\). Find the surface concentration of...
-
Find the mobility of \(\mathrm{H}^{+}, \mathrm{OH}^{-}\), and other ions from the diffusivity data given in Table 22.1. Table 22.1. Diffusion coefficients of ions in water at 25 C. H+ Na+ K+ Ca+ OH-...
Study smarter with the SolutionInn App