- The goal of this project was to investigate the addition of parameterized types to the Java programming language. Two different parametric polymorphism mechanisms were developed and compared. The first was a preprocessor and the second was a compiler.
Parameterized types allow a programmer to create generic programs. Much as a function parameter allows the value of a variable to be changed each time the function is called, a type parameter allows the type of a variable to be changed. This allows the creation of classes that can have the type on which they operate specified at compile time.
The principal reason for parameterized types is code reuse. Generic and efficient type-safe libraries are easily created which programmers can instantiate with a type parameter when the library is needed. This research creates a mechanism that allows two similar classes that differ only in the type of value they operate on to share the same function bodies. Two of the main benefits are reducing programming time and reducing errors in the program[Stroustrup91].
Parameterized types allow for the easy creation of reusable libraries. For example, the Standard Template Library (STL) in C++ relies heavily on parameterized types.