Consider the following pseudocode: x : integer global procedure set x(n : integer) x := n

Question:

Consider the following pseudocode:
x : integer –– global
procedure set x(n : integer)
x := n
procedure print x()
write integer(x)
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()
else
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?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Programming Language Pragmatics

ISBN: 9780124104099

4th Edition

Authors: Michael L. Scott

Question Posted: