Soft typing

Type systems are designed to prevent the improper use of program operations. They can be classified as either static or dynamic depending on when they detect type errors. Static type systems detect potential type errors at compile-time and prevent program execution. Dynamic type systems detect type errors at run-time and abort program execution.Static type systems have two important advantages over dynamic type systems. First, they help programmers detect a large class of program errors before execution. Second, they extract information that a compiler can exploit to produce more efficient code. The price paid for these advantages, however, is a loss of expressiveness, generality, and semantic simplicity.This paper presents a generalization of static and dynamic typing---called soft typing---that combines the best features of both approaches. The key idea underlying soft typing is that a static type checker need not reject programs that contain potential type errors. Instead, the type checker can insert explicit run-time checks around "suspect" arguments of primitive operations, converting dynamically typed programs into statically type-correct form. The inserted run-time checks identify program phrases that may be erroneous. For soft typing to be effective, the type system must avoid inserting unnecessary run-time checks. To accomplish this objective, we have developed an extension of the ML type system supporting union types and recursive types that assigns types to a wider class of programs than ML. We have also developed an algorithm for frugally inserting run-time checks in programs that do not type check.

[1]  Didier Rémy,et al.  Type checking records and variants in a natural extension of ML , 1989, POPL '89.

[2]  Satish R. Thatte Quasi-static typing , 1989, POPL '90.

[3]  Prateek Mishra,et al.  Polymorphic Subtype Inference: Closing the Theory-Practice Gap , 1989, TAPSOFT, Vol.2.

[4]  William D. Clinger,et al.  Revised3 report on the algorithmic language scheme , 1986, SIGP.

[5]  Luca Cardelli,et al.  Subtyping recursive types , 1991, POPL '91.

[6]  Carsten K. Gomard Partial type inference for untyped functional programs , 1990, LISP and Functional Programming.

[7]  Ravi Sethi,et al.  A semantic model of types for applicative languages , 1982, LFP '82.

[8]  Prateek Mishra,et al.  Type Inference with Subtypes , 1990, Theor. Comput. Sci..

[9]  M. Tofte Operational Semantics and Polymorphic Type Inference , 1988 .

[10]  Robert Cartwright,et al.  A constructive alternative to axiomatic data type definitions , 1980, LISP Conference.

[11]  Peter D. Mosses,et al.  Denotational semantics , 1995, LICS 1995.

[12]  Prateek Mishra,et al.  Design and implementation of a functional language with subtypes , 1989 .

[13]  John C. Mitchell,et al.  Coercion and type inference , 1984, POPL.

[14]  Andrew W. Appel,et al.  Standard ML of New Jersey , 1991, PLILP.

[15]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[16]  Robert Harper,et al.  Typing first-class continuations in ML , 1991, POPL '91.

[17]  Daniel P. Friedman,et al.  The little LISPer , 1974 .

[18]  Luís Damas Type assignment in programming languages , 1984 .

[19]  Alexander Aiken,et al.  Static type inference in a dynamically typed language , 1991, POPL '91.

[20]  Robin Milner,et al.  Definition of standard ML , 1990 .

[21]  Gordon D. Plotkin,et al.  An ideal model for recursive polymorphic types , 1984, Inf. Control..

[22]  Mitchell Wand,et al.  Complete Type Inference for Simple Objects , 1987, LICS.

[23]  Mike Fagan,et al.  Soft typing: an approach to type checking for dynamically typed languages , 1992 .

[24]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

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

[26]  Pavel Curtis Constrained qualification in polymorphic type analysis , 1990 .