-
25
pages
-
English
-
Documents
Description
TMGJ: Extending the Java programming language with typeparametersGilad Bracha, Sun MicrosystemsMartin Odersky, University of South AustraliaDavid Stoutamire, SunPhilip Wadler, Bell Labs, Lucent TechnologiesMarch 1998; revised August 1998Say you wish to process collections. Some may be collections of bytes, others collec-tions of strings, and yet others collections of collections of strings. The Java program-ming language supports such variation by allowing you to form a collection of Object,so the elements may have any reference type. In order to keep the language simple,you are forced to do some of the work yourself: you must keep track of the fact thatyou have a collection of bytes, and when you extract an element from the collection youmust cast it to class Byte before further processing.This situation is becoming more common as the Java platform evolves, notably withthe addition of collection classes to JDK 1.2. Other languages provide additional supportfor this situation: in C++, it is supported with templates; in Ada, it is supported withgenerics; and in ML and Haskell, it is supported with parametric polymorphism.This note proposes GJ, an extension to the Java programming language that sup-ports types with parameters. GJ programs look much like the equivalent Java programs,except they have more type information and fewer casts. The semantics of GJ is givenby a translation into the Java programming language. The translation erases type ...
-
Publié par
-
Langue
English