Type dispatch for named hierarchical types

Type dispatch constructs are an important feature of many programming languages. Scheme has predicates for testing the runtime type of a value. Java has a class cast expression and a try statement for switching on an exception's class. Crucial to these mechanisms, in typed languages, is type refinement: The static type system will use type dispatch to refine types in successful branches. Considerable previous work has addressed type case constructs for structural type systems without subtyping, but these do not extend to named type systems with subtyping, as is common in object oriented languages. Previous work on type dispatch in named type systems with subtyping has not addressed its implementation formally.This paper describes a number of type dispatch constructs that share a common theme: class cast and class case constructs in object oriented languages, ML style exceptions, hierarchical extensible sums, and multimethods. I describe a unifying mechanism, tagging, that abstracts the operation of these constructs, and I formalise a small tagging language. After discussing how to implement the tagging language, I present a typed language without type dispatch primitives, and a give a formal translation from the tagging language.

[1]  Giuseppe Castagna,et al.  A calculus for overloaded functions with subtyping , 1992, LFP '92.

[2]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[3]  Matthias Felleisen,et al.  Abstract models of memory management , 1995, FPCA '95.

[4]  Harold Abelson,et al.  Revised5 report on the algorithmic language scheme , 1998, SIGP.

[5]  Karl Crary,et al.  From system F to typed assembly language , 1999 .

[6]  Martín Abadi,et al.  A Theory of Objects , 1996, Monographs in Computer Science.

[7]  Giuseppe Castagna,et al.  A Calculus for Overloaded Functions with Subtyping , 1995, Inf. Comput..

[8]  John H. Reppy,et al.  Simple objects for Standard ML , 1996, PLDI '96.

[9]  Paul Carus,et al.  The Derivation of , 1908 .

[10]  Robert Harper,et al.  An Interpretation of Standard ML in Type Theory , 1997 .

[11]  Craig Chambers,et al.  The cecil language: specification and rationale , 1993 .

[12]  John H. Reppy,et al.  The design of a class mechanism for Moby , 1999, PLDI '99.

[13]  Jonathan Rees,et al.  Revised3 report on the algorithmic language scheme , 1986, SIGP.

[14]  Greg Morrisett,et al.  Compiling with Types , 1995 .

[15]  Karl Crary,et al.  Intensional polymorphism in type-erasure semantics , 1998, ICFP '98.

[16]  D. H. Bartley,et al.  Revised4 report on the algorithmic language scheme , 1991, LIPO.

[17]  Dan Grossman,et al.  TALx86: A Realistic Typed Assembly Language∗ , 1999 .

[18]  Martín Abadi,et al.  Dynamic typing in a statically-typed language , 1989, POPL '89.

[19]  R. Kent Dybvig,et al.  Revised5 Report on the Algorithmic Language Scheme , 1986, SIGP.

[20]  Karl Crary,et al.  Flexible type analysis , 1999, ICFP '99.

[21]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.