Reading Exercise #5
Due 5:00 PM, Tuesday Feb. 23, 2015

Content of reading exercise #5

  1. What are some of the drawbacks of parametric polymorphism?
  2. Discuss some of the ways that generics are implemented.
  3. What is the difference between a generic subroutine and a macro? Why prefer one over the other?
  4. What is the main purpose of having generic subroutines and classes in a language?
  5. Give an example, not mentioned in the text, of a case where a generic subroutine or class would be useful. Can you write the code for this example in Java, C++, or C#?
  6. How do Haskell type classes support generic programming? (Note: you may need to look this up online)
  7. If you were writing your own compiler, how would you deal with generic classes? In what way would you decide how to store instances of a generic class in memory? How might allowing generic classes in your language impact your type system implementation?