Dynamic typing as staged type inference

Mark Shields, Tim Sheard, Simon Peyton Jones
1998 Proceedings of the 25th ACM SIGPLAN-SIGACT symposium on Principles of programming languages - POPL '98  
Dynamic typing extends statically typed languages with a universal datatype, simplifying programs which m ust manipulate other programs as data, such as distributed, persistent, interpretive and generic programs. Current approaches, however, limit the use of polymorphism in dynamic values, and can be syntactically awkward. We introduce a new approach to dynamic typing, based on staged computation, which allows a single typereconstruction algorithm to execute partly at compile time and partly at
more » ... run-time. This approach seamlessly extends a single type system to accommodate types that are only known at run-time, while still supporting both type inference and polymorphism. The system is signi cantly more expressive than other approaches. Furthermore it can be implemented e ciently; most of the type inference is done at compile-time, leaving only some residual uni cation for run-time. We demonstrate our approach b y examples in a small polymorphic functional language, and present its type system, type reconstruction algorithm, and operational semantics. Our proposal could also be readily adapted to many other programming languages.
doi:10.1145/268946.268970 dblp:conf/popl/ShieldsSJ98 fatcat:aghidzngjzccvfz7mjtswkic2y