Skip to main content

Predict before evaluating

  1. Draw the defining and calling environments for x=10, f(y)=x+y, inner x=99, f(2). Predict both lexical and caller-scope results.
  2. Build make(x)=lambda y:x+y. Keep make(-3) and make(8) alive together; alternate calls with 2. Explain which frames are shared and which are distinct.
  3. Construct a true conditional with an unbound dead branch, then reverse the condition. Predict the first failing lookup. Contrast with an eager unused function argument.
  4. Count visited nodes for add(1,2) and predict fuel 0, 2 and 3. Give an operation whose cost is not captured accurately by this count.
  5. Design the change needed for set! to update the nearest existing binding. Predict two closures over the same location. This is a paper extension, not a claim that the supplied interpreter supports mutation.
  6. Compare a tail-recursive guest program with the host call stack. Sketch a loop or explicit continuation representation. Explain why the current lab cannot promise constant stack usage.

Submit predictions before execution and corrections afterward. Preserve incorrect predictions in the mistake log. Use fresh names and values for the delayed assessment.