

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CMSC 330, Spring 2009, Midterm 2 Practice Problems
a. What value is returned by the invocation of f( ) with static scoping? Explain. b. What value is returned by the invocation of f( ) with dynamic scoping? Explain.
Consider the following OCaml code. let app f w = let x = 1 in f w ;; let add x y = let incr z = z+x in app incr y;; (add 2 3) ;;
c. What is the order of invocation for the functions app, add, and incr when evaluating the expression (add 2 3)? d. What value is returned by (add 2 3) with static scoping? Explain. e. What value is returned by by (add 2 3) with dynamic scoping? Explain.