(a) What does this program print if the language uses static scoping? (b) What d
ID: 3862907 • Letter: #
Question
(a) What does this program print if the language uses static scoping? (b) What does it print if the language uses dynamic scoping with deep binding? (c) What does it print if the language uses dynamic scoping with shallow binding?
1 x integer 3 procedure set-x (n integer 6 procedure print-x write-integer (x) 9 procedure foo (S,P function n integer) x integer 0 10 if n in 12,3 12 set -x (n) 13 else S(n) 14 if n in 13,4 15 16 print -x 17 else 18 19 20 set-x (4); foo (set-x print-x,1); prin t-x 21 set -x (0); foo (set-x print-x ,2); print-x 22 set-x (1); foo (set-x print-x,3); print-x 23 set-x (3); foo (set-x print x ,4); print-xExplanation / Answer
(a) What does this program print if the language uses static scoping?
prints 4,0,1,3
(b) What does it print if the language uses dynamic scoping with deep binding?
prints 1,2,3,4
(c) What does it print if the language uses dynamic scoping with shallow binding?
prints 1,2,1,3
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.