Retro printing press University of Washington Department of Computer Science & Engineering
 CSE583 Assignment 1 (Winter 2000)
  CSE Home  About Us    Search    Contact Info 

See the basic page on assignments for program weights, rules for working in pairs, etc.

This assignment is due on Friday, February 11, 2000 at 5PM PST.  We will make an announcement later about the specific electronic form for turning in the assignment.  

There is no programming for this assignment!  

  1. (21 points) This question concerns abstract types and subtypes, parameterized types, and the contravariant rule. We have an abstract type Consumer, parameterized by T, the type of object that the Consumer consumes. Consumer has a single operation eat, which takes a single argument of type T and doesn't return anything.   We also have an abstract type Producer, again parameterized by T. Producer has a single operation make, which takes no arguments and returns an object of type T.  Finally we have an abstract type ProducerConsumer, again parameterized by T, the type of object that the ProducerConsumer contains. ProducerConsumer has two operations: eat and make.  Using the contravariant rule, what is the subtype relation between the following pairs of types? (The answer to each question would be either X is a subtype of Y, Y is a subtype of X, or neither is a subtype of the other.)
    1. ProducerConsumer[Integer] and ProducerConsumer[Number]
    2. Consumer[Integer] and Consumer[Number]
    3. Producer[Integer] and Producer[Number]
    4. ProducerConsumer[Integer] and Producer[Number]
    5. ProducerConsumer[Number] and Producer[Integer]
    6. ProducerConsumer[Integer] and Consumer[Number]
    7. ProducerConsumer[Number] and Consumer[Integer]

  2. (21 points) The same as the previous question, except use the covariant rule. If the covariant rule gives an incorrect answer, sketch a program that breaks; or one that will always execute without type errors, even though the covariant rule says it is incorrect.
  3. (20 points) Give two realistic examples of object-oriented programs in which static type checking is too restrictive. (You don't have to write out the program, just describe the situation.)
  4. (14 points) Multi-methods tend to reduce the size of programs.  Argue concisely (no more than a paragraph) about whether you believe that multi-methods tend to make those programs easier to understand and to change.  
  5. (24 points) For each of the following, state whether it would be relatively straightforward to achieve using the metaobject protocol.  Briefly justify each answer.
    1. Track the number of invocations of each function in the program.
    2. Replace a classic garbage collector for reclaiming memory with a reference counting engine.
    3. Implement multi-methods.
    4. Change CLOS multiple inheritance from linearizing all instance variables in the (multiple inheritance) hierarchy to another policy (such as not permitting any conflicts in the names of instance variables).

 

 


CSE logo Department of Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA  98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to notkin@cs.washington.edu]