CSE 130: PROGRAMMING LANGUAGES: PRINCIPLES AND PARADIGMS
Final Exam, 17 March 2002

You may write your answers on this sheet; be sure to write your name on every sheet you hand in.
  1. [12 pts] Briefly answer the following, giving examples at least for 1 and 3:
    1. What is the dangling else problem?
    2. Define l-value and r-value.
    3. Define copy-in/copy-out.
    4. What is a closure?

  2. [18 pts]
    1. What is a narrowing coercion? Why is implicit narrowing coercion dangerous? Give an example.
    2. What is dynamic scoping, and what are its main disadvantages?

  3. [18 pts]
    1. Describe both declarative and operational meanings for the following Prolog program, in which s(N) denotes the successor of N (i.e., N+1): l([], 0). l([X|Xs], s(N)) :- l(Xs, N).
    2. Give a simple, but not entirely trivial, example of its execution, with a graph showing the search space for its computation.

  4. [6 pts]
    1. Name two important languages developed by the US Department of Defense.
    2. Who were their chief designers?

  5. [18 pts] Define three different kinds of polymorphism and give an example of each.
     
  6. [16 pts] What is the type of the following ML function? (fn y => (let f = (fn x => x) in ((f y)+1, (f true)) end)) Why? (You may use either Stansifer's mini-ML or the real ML as a basis; in the latter case, substitute let val f for let f in the above. An intuitive discussion is sufficient; you do not need to use Stansifer's Post system.)
     
  7. [12 pts] For each of the following: are the two terms unifiable or not; if they are, what is their most general unifier; and in either case, why. (a) f(f(X,Y),Y) f(f(X,X),X) (b) f(f(X,Y),Y) f(g(X,Y),Y) (c) f(f(X)) X (d) f(g(X,Y),h(X)) f(Z,h(g(Z,X)))

To CSE 130 homepage
Maintained by Joseph Goguen
© 2002 Joseph Goguen