Assignment 4, Scoping and data types
Due 9/21/04 12:30 p.m.
(Must be done with your group)

  1. [Skill 6.3] The textbook defines two kinds of scoping: static and dynamic.  Use this link to figure out if MYSTERY uses static or dynamic scoping.  As in the previous assignment your write up should describe the kind of scoping that MYSTERY uses and provide evidence for your conclusions.  You may submit no more than three programs for this question.  Programs that have parse errors (i.e., syntax errors) do not count.  Every additional program will cost you 5% of the points for this question.
  2. [Synthesis] Some languages do all type checking at compile time; these are called statically typed languages.  Can a language that uses dynamic scoping be statically typed?  Provide examples to support your answer.
  3. [Skill 6.3] Does Java use static or dynamic scoping?  Support your answer either with quotes from the Java language definition (available in the "interesting links" section of the class web page) or with examples and their output (much like how you use the PL Detective) from a Java compiler.
  4. [Skill 6.2] Consider procedures A, B, C, D, and E.  Let's suppose that we have the following requirements:

    A needs to call B and C
    B needs to call C and E
    C needs D
    D needs to call E

    Show how you would accomplish the above in a statically scoped language.  You should try to organize things so that, to the best of your ability, all procedures that do not need to be called from a procedure must be hidden.  (Note that it may not be possible to do this completely: you just need to give it your best shot).

  5. [Skill 6.1] Page 226, Problem set #8
  6. [Skill 7.4] Give one example where associative arrays are more suitable than arrays found in C++.  Give one example where C++ arrays are more suitable than associative array.  Your examples should be accompanied by an explanation and justification. 
  7. [Skill 7.3] Give a concrete and realistic example that uses a union type.  By realistic I mean that the example should be motivated by a "real-world" situation and not be abstract.
  8. [Skill 7.1] Give a concrete and realistic example that uses a subrange type.
  9. [Skill 7.2] Give a concrete and realistic example that uses a enumeration type.