Compiling polymorphism using intensional type analysis

R Harper, G Morrisett - Proceedings of the 22nd ACM SIGPLAN-SIGACT …, 1995 - dl.acm.org
Proceedings of the 22nd ACM SIGPLAN-SIGACT symposium on Principles of …, 1995dl.acm.org
Traditional techniques for implementing polymorphism use a universal representation for
objects of unknown type. Often, this forces a compiler to use universal representations even
if the types of objects are known. We examine an alternative approach for compiling
polymorphism where types are passed as arguments to polymorphic routines in order to
determine the representation of an object. This approach allows monomorphic code to use
natural, efficient representations, supports separate compilation of polymorphic definitions …
Traditional techniques for implementing polymorphism use a universal representation for objects of unknown type. Often, this forces a compiler to use universal representations even if the types of objects are known. We examine an alternative approach for compiling polymorphism where types are passed as arguments to polymorphic routines in order to determine the representation of an object. This approach allows monomorphic code to use natural, efficient representations, supports separate compilation of polymorphic definitions and, unlike coercion-based implementations of polymorphism, natural representations can be used for mutable objects such as refs and arrays.
We are particularly interested in the typing properties of an intermediate language that allows run-time type analysis to be coded within the language. This allows us to compile many representation transformations and many language features without adding new primitive operations to the language. In this paper, we provide a core target language where type-analysis operators can be coded within the language and the types of such operators can be accurately tracked. The target language is powerful enough to code a variety of useful features, yet type checking remains decidable. We show how to translate an ML-like language into the target language so that primitive operators can analyze types to produce efficient representations. We demonstrate the power of the “user-level” operators by coding flattened tuples, marshalling, type classes, and a form of type dynamic within the language.
ACM Digital Library
以上显示的是最相近的搜索结果。 查看全部搜索结果