Reading Exercise #5
Due 8:00 AM, Monday Feb. 15, 2016
Content of reading exercise #5
- What are some of the drawbacks of parametric polymorphism?
- Discuss some of the ways that generics are implemented.
- What is the difference between a generic subroutine and a macro? Why prefer one over the other?
- What is the main purpose of having generic subroutines and classes in a language?
- 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#?
- How do Haskell type classes support generic programming? (Note: you may need to look this up online)
- 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?