COMPUTER SCIENCE TRIPOS Part IB – 2013 – Paper 3
Compiler Construction (TGG)
(a) Describe the costs and benefits of performing inline expansion of functions during
compilation. [4 marks]
(b) Describe what is meant by eliminating tail recursion, when such an optimization
can be applied and why it is a benefit. [4 marks]
(c) Consider the following ML-like program where the function f returns a function:
let val a = 99 in
let fun f b = let g c = a + b + c in g end
let val f1 = f 17 in
let val f2 = f 33 in
let val v = (f1 a) + (f2 a) in
…
…
Describe carefully how this program fragment could be compiled. Explain how
the expression
(f1 a) + (f2 a)
would be evaluated by your compiled code. [12 marks]