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.
- [12 pts] Briefly answer the following, giving examples at least for 1 and
3:
- What is the dangling else problem?
- Define l-value and r-value.
- Define copy-in/copy-out.
- What is a closure?
- [18 pts]
- What is a narrowing coercion? Why is implicit narrowing coercion
dangerous? Give an example.
- What is dynamic scoping, and what are its main disadvantages?
- [18 pts]
- 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).
- Give a simple, but not entirely trivial, example of its execution,
with a graph showing the search space for its computation.
- [6 pts]
- Name two important languages developed by the US Department of
Defense.
- Who were their chief designers?
- [18 pts] Define three different kinds of polymorphism and give an example
of each.
- [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.)
- [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