Abstract
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.
References
- Alain Colmerauer. Prolog and infinite trees. In K. L. Clark and S. A. Tarnlund, editors, Logic Programming, pages 231--251. Academic Press, 1982.Google Scholar
- Luis Damas and Robin Milner. Principal type-schemes for functional programs. In Conference Record of the Ninth Annual ACM Symposium on Principles of Programming Languages, 1982. Google Scholar
Digital Library
- C. Flanagan, M. Flatt, S. Krishnamurthi, S. Weirich, and M. Felleisen. Catching bugs in the web of program invariants. In Proceedings of the 1996 Conference on Programming Language Design and Implementation (PLDI), 1996. Google Scholar
Digital Library
- Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 1978.Google Scholar
Cross Ref
- F. Pessaux and X. Leroy. Type-based analysis of uncaught exceptions. In Symposium on the Principles of Programming Languages, 1999. Google Scholar
Digital Library
- Didier Rémy. Typechecking records and variants in a natural extension of ml. In Conference Record of the Sixteenth Annual ACM Symposium on Principles of Programming Languages, 1989. Google Scholar
Digital Library
- R. A. Tapia. On the role of slack variables in quasi-newton methods for unconstrained optimization. In Numerical Optimization of Dynamical Systems. L. C. W. Dixon, 1980.Google Scholar
- Mads Tofte. Operational Semantics and Polymorphic Type Inference. PhD thesis, University of Edinburgh, 1987.Google Scholar
- A. Wright and R. Cartwright. A practical soft type system for Scheme. In Proceedings of Conference on LISP and functional Programming, 1994. Google Scholar
Digital Library
- Martin Abadi, Luca Cardelli, Benjamin Pierce, and Gordon Plotkin. Dynamic typing in a statically typed language. In Proceedings of the Sixteenth POPL Symposium, 1989. Google Scholar
Digital Library
- Alexander Aiken and Brian Murphy. Static type inference in a dynamically typed language. In Proceedings of the 18th Annual Symposium on Principles of Programming Languages, 1991. To appear. Google Scholar
Digital Library
- Andrew W. Appel and David MacQueen. Standard ML of New Jersey Reference Manual. (in preparation), 1990.Google Scholar
- Robert Cartwright. A constructive alternative to axiomatic data type definitions. In Proceedings of 1980 LISP Conference, 1980. Google Scholar
Digital Library
- William Clinger and Jonathan Rees. Revised3.99Report on the Algorithmic Language Scheme, August 1990.Google Scholar
- Alain Colmerauer. Prolog and infinite trees. In K. L. Clark and S. A. Tarnlund, editors, Logic Programming, pages 231--251. Academic Press, 1982.Google Scholar
- Pavel Curtis. Constrained quantification in polymorphic type analysis. Technical Report CSL-90-1, Xerox PARC, 1990.Google Scholar
- Luis Damas and Robin Milner. Principal type-schemes for functional programs. In Conference Record of the Ninth Annual ACM Symposium on Principles of Programming Languages, 1982. Google Scholar
Digital Library
- Luis Manuel Martins Damas. Type Assignment in Programming Languages. PhD thesis, University of Edinburgh, 1985.Google Scholar
- Bruce F. Duba, Robert Harper, and David MacQueen. Typing first-class continuations in ML. In Conference Record of the Eighteenth Annual ACM Symposium on Principles of Programming Languages, 1991. Google Scholar
Digital Library
- Mike Fagan. Soft Typing: An Approach to Type Checking for Dynamically Typed Languages. PhD thesis, Rice University, 1990. Google Scholar
Digital Library
- You-Chin Fuh and Prateek Mishra. Type inference with subtypes. In Conference Record of the European Symposium on Programming, 1988. Google Scholar
Digital Library
- You-Chin Fuh and Prateek Mishra. Polymorphic subtype inference: Closing the theory-practice gap. In TAPSOFT, 1989. Google Scholar
Digital Library
- Carsten K. Gomard. Partial type inference for untyped functional programs. In Proceedings of the 1990 ACM Conference on LISP and Functional Programming, 1990. Google Scholar
Digital Library
- Gérard Huet. Résolution d'équations dans les langages d'ordre 1,2,.., ω. PhD thesis, Université Paris, 7 1976.Google Scholar
- D. MacQueen, G. Plotkin, and R. Sethi. An ideal model for recursive polymorphic types. In Conference Record of the Eleventh Annual ACM Symposium on Principles of Programming Languages, 1983. Google Scholar
Digital Library
- D. B. MacQueen and Ravi Sethi. A semantic model of types for applicative languages. In Conference Record of the Tenth Annual ACM Symposium on Principles of Programming Languages, 1982.Google Scholar
Cross Ref
- Robin Milner. A theory of type polymorphism in programming. Journal of Computer and System Sciences, 1978.Google Scholar
Cross Ref
- Robin Milner, Mads Tofte, and Robert Harper. The Definition of Standard ML. MIT Press, 1990. Google Scholar
Digital Library
- John C. Mitchell. Coercion and type inference. In Conference Record of the Eleventh Annual ACM Symposium on Principles of Programming Languages, 1983. Google Scholar
Digital Library
- Dider Rémy. Typechecking records and variants in a natural extension of ml. In Conference Record of the Sixteenth Annual ACM Symposium on Principles of Programming Languages, 1989. Google Scholar
Digital Library
- David A Schmidt. Denotational Semantics. Allyn and Bacon, Inc, 1986.Google Scholar
Digital Library
- Sattish Thatte. Quasi-static typing. In Proceedings of the Seventeenth POPL Symposium, 1990. Google Scholar
Digital Library
- Mads Tofte. Operational Semantics and Polymorphic Type Inference. PhD thesis, University of Edinburgh, 1987.Google Scholar
- Mitchell Wand. Complete type inference for simple objects. In Proceedings of the Second Symposium on Logic in Computer Science, 1987.Google Scholar





Comments