3.18 Consider the following pseudocode: x : integer procedure set_x(n: integer) x := n ➖➖➖➖ procedure print_x() global write integer (x) else procedure foo (S, P: function; n : integer) x: integer := 5 if n in (1, 3) set_x (n) else S(n) if n in {1, 2} print_x() P 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 the program print if the language uses shallow binding? What does it print with deep binding? Why?
3.18 Consider the following pseudocode: x : integer procedure set_x(n: integer) x := n ➖➖➖➖ procedure print_x() global write integer (x) else procedure foo (S, P: function; n : integer) x: integer := 5 if n in (1, 3) set_x (n) else S(n) if n in {1, 2} print_x() P 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 the program print if the language uses shallow binding? What does it print with deep binding? Why?
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
Related questions
Question
Please help me with this Principles of programming language homework question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning