Compiling polymorphism using intensional type analysis

Robert Harper, Greg Morrisett
1995 Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages - POPL '95  
Types have been used to describe the size and shape of data structures at compile time. In polymorphic languages or languages with abstract types, this is not possible since the types of some objects are not known at compile time. Consequently, most implementations of polymorphic languages box data (i.e., represent an object as a pointer), leading to inefficiencies. We introduce a new compilation method for polymorphic languages that avoids the problems associated with boxing data. The
more » ... al idea is to relax the requirement that code selection for primitive, polymorphic operations, such as pairing and projection, must be performed at compile time. Instead, we allow such operations to defer code selection until link-or even run-time when the types of the values are known. We formalize our approach as a translation into an explicitly-typed, predicative polymorphic Acalculus with intensional polymorphism. By "intensional polymorphism", we mean that constructors and terms can be constructed via structural recursion on types. The form of intensional analysis that we provide is sufficiently strong to perform non-trivial type-based code selection, but it is sufficiently weak that termination of operations that analyze types is assured. This means that a compiler may always "open code" intensionally polymorphic operations as soon as the type argument is known -the properties of the target language ensure that the specialization will always terminate. We illustrate the use of intensional polymorphism by considering a "flattening" translation for tuples and a "marshalling" operation for distributed computing. We briefly consider other applications including type classes, Dynamic types, and "views". oooseslon For . 7TI ýS (/ A. ..
doi:10.1145/199448.199475 dblp:conf/popl/HarperM95 fatcat:riqfonffxjfd7hekrsroj5vjce