Midterm 1, CSCI 3155
February 17th, 2004

You have 70 minutes to answer these questions.  Please read all questions before you start.  This is a closed-book exam.  The points for a question are split evenly between its parts.  Please remember that you are bound by the CU honor code.

  1. [24 points] For each of the following indicate whether it is part of the syntax of the language or part of the semantics.  Support your answers with explanations.
    1. Operand evaluation order
    2. The form of variable names
    3. The requirement that each "BEGIN" in a MYSTERY program has a matching "END"
    4. The requirement that the types of the lhs and rhs of an assignment must be equal.
  2. [30 points] We discussed two kinds of garbage collectors: reference counting and mark-and-sweep.  Answer the following questions.  Be explicit and provide explanations for your answers.
    1. Can one use reference counting with all languages or only with some languages?
    2. Can one use mark-and-sweep with all languages or only with some languages?
    3. What work needs to be performed at each pointer assignment to support reference counting?
    4. What work needs to be performed at each pointer assignment to support mark-and-sweep?
    5. Which collector will have longer pause times?  Mark and sweep or reference counting?
  3. [20 points] For each of the following storage bindings, describe what it is and also describe the properties of the variables using the storage binding in question:
    1. static
    2. stack dynamic
    3. explicit heap dynamic
    4. implicit heap dynamic
  4. [26 points] This question concerns static and dynamic scoping
    1. Give an example program in MYSTERY syntax that would produce different answers with static and dynamic scoping.  Explain why your program produces the different answers.
    2. Let's suppose MYSTERY uses dynamic scoping and allows assignments only between variables of the same type.  Given these conditions, can MYSTERY do all type checking at compile time?  Give justification for your answer.