hw7 - COP4020 Spring 2011 Homework Assignment 7 1. Consider...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
COP4020 Spring 2011 Homework Assignment 7 1. Consider the following pseudo-code program: sum : integer // a global variable procedure add(amount : integer) sum := sum + amount procedure p(x : integer, adder : procedure) integer sum sum := x adder(x) // invoke procedure that was passed as argument write_integer(sum) begin // main program sum := 0 p(1, add) end a. Suppose dynamic scoping with shallow binding is used by the interpreter to execute this code. What is the value printed by the program? b. Suppose dynamic scoping with deep binding is used by the interpreter to execute this code. What is the value printed?
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online