(Solved):
4. (24 pts) Consider the following pseudo-code: \( x \) : integer; \( \quad- \) global procedure s ...
4. (24 pts) Consider the following pseudo-code: \( x \) : integer; \( \quad- \) global procedure set \( x \) (n : integer) \( \mathrm{x}:=\mathrm{n} \); procecure print_x write_integer \( \langle x\rangle \); procedure foo \( (S, p \) : procedure; \( n \) : integer) \( \mathrm{x} \) : integer; if \( \mathrm{n} \) in \( \{1,3\} \) set_x(n); else \( S(\mathrm{n}) ; \) if \( \mathrm{n} \) in \( \{1,2\} \) else print_x; 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.