Dynamic typing in a statically-typed language

Statically-typed programming languages allow earlier error checking, better enforcement of disciplined programming styles, and generation of more efficient object code than languages where all type-consistency checks are performed at runtime. However, even in statically-type languages, there is often the need to deal with data whose type cannot be known at compile time. To handle such situations safely, we propose to add a type Dynamic whose values are pairs of a value v and a type tag T where v has the type denoted by T. Instances of Dynamic are built with an explicit tagging construct and inspected with a type-safe typecase construct. This paper is an exploration of the syntax, operational semantics, and denotational semantics of a simple language with the type Dynamic. We give examples of how dynamically-typed values might be used in programming. Then we discuss an operational semantics for our language and obtain a soundness theorem. We present two formulations of the denotational semantics of this language and relate them to the operational semantics. Finally, we consider the implications of polymorphism and some implementation issues.

[1]  Bernard Robinet,et al.  Combinators and functional programming languages : Thirteenth Spring School of the LITP, Val d'Ajol, France, May 6-10, 1985, proceedings , 1986 .

[2]  Gilles Kahn,et al.  Natural Semantics , 1987, STACS.

[3]  R. Scheifler A DENOTATIONAL SEMANTICS OF CLU , 1978 .

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

[5]  Paul Rovner Extending Modula-2 to Build Large, Integrated Systems , 1986, IEEE Software.

[6]  Alonzo Church,et al.  A formulation of the simple theory of types , 1940, Journal of Symbolic Logic.

[7]  Luca Cardelli. Amber Combinators and Functional Programming Languages , 1985, Lecture Notes in Computer Science.

[8]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[9]  Joëlle Despeyroux,et al.  Proof of Translation in Natural Semantics , 1986, LICS.

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

[11]  Patrick Borras,et al.  Centaur: the system , 1988, Software Development Environments.

[12]  Luca Cardelli,et al.  Modula-3 Report. , 1988 .

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

[14]  Gordon D. Plotkin,et al.  Call-by-Name, Call-by-Value and the lambda-Calculus , 1975, Theor. Comput. Sci..

[15]  Robin Milner,et al.  The semantics of standard LM Version 1: LFCS report ECS-LFCS-87-36 , 1987 .

[16]  Dominique Clément,et al.  Natural semantics on the computer , 1984 .

[17]  Craig Schaffert,et al.  CLU Reference Manual , 1984, Lecture Notes in Computer Science.

[18]  J. Melek [The system]. , 1973, Pielegniarka i polozna.

[19]  Per Martin-Löf,et al.  Intuitionistic type theory , 1984, Studies in proof theory.

[20]  Andrew Birrell,et al.  Implementing remote procedure calls , 1984, TOCS.

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

[22]  Peter Buneman,et al.  Types and persistence in database programming languages , 1987, CSUR.

[23]  J. Girard Une Extension De ĽInterpretation De Gödel a ĽAnalyse, Et Son Application a ĽElimination Des Coupures Dans ĽAnalyse Et La Theorie Des Types , 1971 .

[24]  Robert Harper Introduction to standard ml , 1986 .

[25]  Joseph M. Newcomer Efficient binary I/O of IDL objects , 1987, SIGP.

[26]  J. Roger Hindley,et al.  Introduction to combinators and λ-calculus , 1986, Acta Applicandae Mathematicae.

[27]  Luca Cardelli,et al.  Persistence and Type Abstraction , 1985, Data Types and Persistence , Informal Proceedings.

[28]  Skef Wholey,et al.  Internal design of CMU common Lisp on the IBM RT PC , 1987 .

[29]  Dominique Clément,et al.  A simple applicative language: mini-ML , 1986, LFP '86.

[30]  Ronald Morrison,et al.  Polymorphic Names and Iterations , 1990, DBPL.

[31]  John C. Reynolds,et al.  Three Approaches to Type Structure , 1985, TAPSOFT, Vol.1.

[32]  Luca Cardelli,et al.  The Modula–3 type system , 1989, POPL '89.

[33]  Bernard Robinet,et al.  Combinators and Functional Programming Languages , 1986 .

[34]  John C. Mitchell,et al.  Abstract types have existential type , 1988, TOPL.