Abstract
We describe universal types, existential types, and type constructors in Cyclone, a strongly typed C-like language. We show how the language naturally supports first-class polymorphism and polymorphic recursion while requiring an acceptable amount of explicit type information. More importantly, we consider the soundness of type variables in the presence of C-style mutation and the address-of operator. For polymorphic references, we describe a solution more natural for the C level than the ML-style “value restriction.” For existential types, we discover and subsequently avoid a subtle unsoundness issue resulting from the address-of operator. We develop a formal abstract machine and type-safety proof that capture the essence of type variables at the C level.
- Abadi, M. and Cardelli, L. 1996. A Theory of Objects. Springer-Verlag, New York, NY.]] Google Scholar
- Appel, A. 1992. Compiling with Continuations. Cambridge University Press, Cambridge, U.K.]] Google Scholar
- Austin, T., Breach, S., and Sohi, G. 1994. Efficient detection of all pointer and array access errors. In Proceedings of the ACM Conference on Programming Language Design and Implementation (Orlando, FL). 290--301.]] Google Scholar
- Benton, N., Kennedy, A., and Russell, G. 1998. Compiling Standard ML to Java bytecodes. In Proceedings of the 3rd ACM International Conference on Functional Programming (Baltimore, MD). 129--140.]] Google Scholar
- Bos, H. and Samwel, B. 2002. Safe kernel programming in the OKE. In Proceedings of the 5th IEEE International Conference on Open Architectures and Network Programming (New York, NY). 141--152.]]Google Scholar
- Botlan, D. L. and Rémy, D. 2003. MLF: Raising ML to the power of System-F. In Proceedings of the ACM International Conference on Functional Programming (Uppsala, Sweden). 27--38.]] Google Scholar
- Bracha, G., Odersky, M., Stoutamire, D., and Wadler, P. 1998. Making the future safe for the past: Adding genericity to the Java programming language. In Proceedings of the 13th ACM Conference on Object-Oriented Programming, Systems, Languages, and Applications (Vancouver, B.C., Canada). 183--200.]] Google Scholar
- Bruce, K., Cardelli, L., and Pierce, B. 1999. Comparing object encodings. Inform. Computat. 155, 108--133.]] Google Scholar
- Cardelli, L. and Wegner, P. 1985. On understanding types, data abstraction, and polymorphism. ACM Comput. Surv. 17, 4, 471--522.]] Google Scholar
- Cejtin, H., Jagannathan, S., and Weeks, S. 2000. Flow-directed closure conversion for typed languages. In 9th European Symposium on Programming. Lecture Notes in Computer Science, vol. 1782. Springer-Verlag, Berlin, Germany, 56--71.]] Google Scholar
- Chailloux, E., Manoury, P., and Pagano, B. 2000. Développement d'Applications avec Objective Caml. O'Reilly, Paris, France. An English translation is currently freely available online at http://caml.inria.fr/oreilly-book/.]]Google Scholar
- Chandra, S. and Reps, T. 1999. Physical type checking for C. In Proceedings of the ACM Workshop on Program Analysis for Software Tools and Engineering (Toulouse, France). 66--75.]] Google Scholar
- Condit, J., Harren, M., McPeak, S., Necula, G., and Weimer, W. 2003. CCured in the real world. In Proceedings of the ACM Conference on Programming Language Design and Implementation. San Diego, CA. 232--244.]] Google Scholar
- Crary, K. 2003. Toward a foundational typed assembly language. In Proceedings of the 30th ACM Symposium on Principles of Programming Languages (New Orleans, LA). 198--212.]] Google Scholar
- Cyclone. 2001. Cyclone user's manual. Tech. rep. 2001-1855. Department of Computer Science, Cornell University, Ithaca, NY. The current version is available online at http://www.cs.cornell.edu/projects/cyclone/.]]Google Scholar
- DeLine, R. and Fähndrich, M. 2001. Enforcing high-level protocols in low-level software. In Proceedings of the ACM Conference on Programming Language Design and Implementation (Snowbird, UT). 59--69.]] Google Scholar
- Ditchfield, G. 1994. Contextual polymorphism. Ph.D. dissertation. University of Waterloo, Waterloo, Onto., Canada.]] Google Scholar
- Garrigue, J. and Rémy, D. 1999. Semi-explicit first-class polymorphism for ML. Inform. Comput. 155, 1/2, 134--169.]] Google Scholar
- Girard, J.-Y., Taylor, P., and Lafont, Y. 1989. Proofs and Types. Cambridge University Press, Cambridge, U.K.]] Google Scholar
- Grossman, D. 2002. Existential types for imperative languages. In 11th European Symposium on Programming. Lecture Notes in Computer Science, vol. 2305. Springer-Verlag, Berlin, Germany, 21--35.]] Google Scholar
- Grossman, D. 2003a. Safe programming at the C level of abstraction. Ph.D. dissertation. Cornell University, Ithaca, NY.]] Google Scholar
- Grossman, D. 2003b. Type-safe multithreading in Cyclone. In Proceedings of the ACM International Workshop on Types in Language Design and Implementation (New Orleans, LA). 13--25.]] Google Scholar
- Grossman, D., Morrisett, G., Jim, T., Hicks, M., Wang, Y., and Cheney, J. 2002. Region-based memory management in Cyclone. In Proceedings of the ACM Conference on Programming Language Design and Implementation (Berlin, Germany). 282--293.]] Google Scholar
- Grossman, D., Zdancewic, S., and Morrisett, G. 2000. Syntactic type abstraction. ACM Trans. Programm. Lang. Syst. 22, 6 (Nov.), 1037--1080.]] Google Scholar
- Harper, R. 1994. A simplified account of polymorphic references. Inform. Process. Lett. 51, 4 (Aug.), 201--206.]] Google Scholar
- Henglein, F. 1993. Type inference with polymorphic recursion. ACM Trans. Programm. Lang. Syst. 15, 2 (Apr.), 253--289.]] Google Scholar
- Hicks, M., Morrisett, G., Grossman, D., and Jim, T. 2004. Experience with safe manual memory-management in Cyclone. In Proceedings of the International Symposium on Memory Management (Vancouver, B.C., Canada).]] Google Scholar
- Hicks, M., Nagarajan, A., and van Renesse, R. 2003. User-specified adaptive scheduling in a streaming media network. In Proceedings of the 6th IEEE International Conference on Open Architectures and Network Programming (San Francisco, CA). 87--96.]]Google Scholar
- ISO. 1999. ISO/IEC 9899:1999, International Standard---Programming Languages---C. International Standards Organization, Geneva, Switzerland.]]Google Scholar
- Jim, T., Morrisett, G., Grossman, D., Hicks, M., Cheney, J., and Wang, Y. 2002. Cyclone: A safe dialect of C. In Proceedings of the USENIX Annual Technical Conference (Monterey, CA). 275--288.]] Google Scholar
- Jones, R. and Kelly, P. 1997. Backwards-compatible bounds checking for arrays and pointers in C programs. In Proceedings of the AADEBUG'97. Third International Workshop on Automatic Debugging. Linköping Electronic Articles in Computer and Information Science, vol. 2(9). Linköping, Sweden.]]Google Scholar
- Jones, S. P. and Hughes, J., Eds. 1999. Haskell 98: A Non-Strict, Purely Functional Language. Available online at http://www.haskell.org/onlinereport/.]]Google Scholar
- Kfoury, A. J., Tiuryn, J., and Urzyczyn, P. 1993. Type reconstruction in the presence of polymorphic recursion. ACM Trans. Programm. Lang. Syst. 15, 2 (Apr.), 290--311.]] Google Scholar
- Kowshik, S., Dhurjati, D., and Adve, V. 2002. Ensuring code safety without runtime checks for real-time control systems. In Proceedings of the ACM International Conference on Compilers, Architectures and Synthesis for Embedded Systems (Grenoble, France). 288--297.]] Google Scholar
- Läufer, K. 1996. Type classes with existential types. J. Funct. Programm. 6, 3 (May), 485--517.]]Google Scholar
- Leroy, X. 1992. Unboxed objects and polymorphic typing. In Proceedings of the 19th ACM Symposium on Principles of Programming Languages (Albuquerque, NM). 177--188.]] Google Scholar
- Leroy, X. 1997. The effectiveness of type-based unboxing. In Proceedings of the Workshop on Types in Compilation (Amsterdam, The Netherlands). Also published as Tech. rep. BCCS-97-03. Computer Science Department, Boston College, Boston, MA.]]Google Scholar
- Leroy, X. 2002a. The Objective Caml System Release 3.05, Documentation and User's Manual. Available online at http://caml.inria.fr/ocaml/htmlman/index.html.]]Google Scholar
- Leroy, X. 2002b. Writing efficient numerical code in Objective Caml. Available online at http://caml.inria.fr/ocaml/numerical.html.]]Google Scholar
- Liskov, B. et al. 1984. CLU Reference Manual. Springer-Verlag, Berlin, Germany.]] Google Scholar
- Loginov, A., Yong, S. H., Horwitz, S., and Reps, T. 2001. Debugging via run-time type checking. In 4th International Conference on Fundamental Approaches to Software Engineering. Lecture Notes in Computer Science, vol. 2029. Springer-Verlag, Berlin, Germany, 217--232.]] Google Scholar
- Milner, R., Tofte, M., Harper, R., and MacQueen, D. 1997. The Definition of Standard ML (Revised). MIT Press, Cambridge, MA.]] Google Scholar
- Minamide, Y., Morrisett, G., and Harper, R. 1996. Typed closure conversion. In Proceedings of the 23rd ACM Symposium on Principles of Programming Languages (St. Petersburg, FL). 271--283.]] Google Scholar
- Mitchell, J. 1988. Polymorphic type inference and containment. Inform. Computat. 76, 11--249.]] Google Scholar
- Mitchell, J. and Plotkin, G. 1988. Abstract types have existential type. ACM Trans. Programm. Lang. Syst. 10, 3 (July), 470--502.]] Google Scholar
- Morrisett, G. 1995. Compiling with types. Ph.D. dissertation, Carnegie Mellon University, Pittsburgh, PA.]]Google Scholar
- Morrisett, G., Crary, K., Glew, N., Grossman, D., Samuels, R., Smith, F., Walker, D., Weirich, S., and Zdancewic, S. 1999a. TALx86: A realistic typed assembly language. In Proceedings of the 2nd ACM Workshop on Compiler Support for System Software (Atlanta, GA). 25--35. Published as INRIA Tech. Rep. 0288. (March 1999), Rocquencourt, France.]]Google Scholar
- Morrisett, G., Crary, K., Glew, N., and Walker, D. 2002. Stack-based typed assembly language. J. Funct. Programm. 12, 1 (Jan.), 43--88.]] Google Scholar
- Morrisett, G., Walker, D., Crary, K., and Glew, N. 1999b. From System F to typed assembly language. ACM Trans. Programm. Lang. Syst. 21, 3 (May), 528--569.]] Google Scholar
- Necula, G., McPeak, S., and Weimer, W. 2002. CCured: Type-safe retrofitting of legacy code. In Proceedings of the 29th ACM Symposium on Principles of Programming Languages (Portland, OR). 128--139.]] Google Scholar
- Patel, P. and Lepreau, J. 2003. Hybrid resource control of active extensions. In Proceedings of the 6th IEEE International Conference on Open Architectures and Network Programming (San Francisco, CA). 23--31.]]Google Scholar
- Patel, P., Whitaker, A., Wetherall, D., Lepreau, J., and Stack, T. 2003. Upgrading transport protocols using untrusted mobile code. In Proceedings of the 19th ACM Symposium on Operating System Principles (New York, NY). 1--14.]] Google Scholar
- Pierce, B. 1991. Programming with intersection types and bounded polymorphism. Ph.D. dissertation, Carnegie Mellon University, Pittsburgh, PA.]] Google Scholar
- Pierce, B. and Sangiorgi, D. 2000. Behavioral equivalence in the polymorphic pi-calculus. J. Assoc. Comp. Mach. 47, 3, 531--584.]] Google Scholar
- Pierce, B. and Turner, D. 1998. Local type inference. In Proceedings of the 25th ACM Symposium on Principles of Programming Languages (San Diego, CA). 252--265.]] Google Scholar
- Reynolds, J. 1974. Towards a theory of type structure. In Programming Symposium. Lecture Notes in Computer Science, vol. 19. Springer-Verlag, Berlin, Germany, 408--425.]] Google Scholar
- Reynolds, J. 1983. Types, abstraction and parametric polymorphism. In Information Processing 83. Elsevier Science Publishers, Amsterdam, The Netherlands, 513--523.]]Google Scholar
- Smith, G. and Volpano, D. 1996. Towards an ML-style polymorphic type system for C. In 6th European Symposium on Programming. Lecture Notes in Computer Science, vol. 1058. Springer-Verlag, Berlin, Germany, 341--355.]] Google Scholar
- Smith, G. and Volpano, D. 1998. A sound polymorphic type system for a dialect of C. Sci. Comput. Programm. 32, 2--3, 49--72.]] Google Scholar
- Strachey, C. 1967. Fundamental concepts in programming languages. Unpublished lecture notes, Summer School in Computer Programming, Copenhagen, Denmark. Eventually published in 2003 in High. Ord. Symbol. Computat. 13, 1-2, 5--6.]] Google Scholar
- Stroustrup, B. 2000. The C++ Programming Language, spec. ed. Addison-Wesley, Reading, MA.]] Google Scholar
- Tarditi, D. 1996. Design and implementation of code optimizations for a type-directed compiler for Standard ML. Ph.D. dissertation. Carnegie Mellon University, Pittsburgh, PA.]]Google Scholar
- The GHC Team. 2003. The Glasgow Haskell Compiler User's Guide, Version 6.0. Available online at http://www.haskell.org/ghc.]]Google Scholar
- The Hugs 98 User Manual. 2002. The Hugs 98 User Manual. Available online at http://haskell.cs.yale.edu/hugs.]]Google Scholar
- Tofte, M. 1990. Type inference for polymorphic references. Inform. Computat. 89, 1--34.]] Google Scholar
- Wadler, P. 1989. Theorems for free! In Proceedings of the 4th International Conference on Functional Programming Languages and Computer Architecture. ACM Press, New York, NY, 347--359.]] Google Scholar
- Walker, D. and Morrisett, G. 2000. Alias types for recursive data structures. In Workshop on Types in Compilation. Lecture Notes in Computer Science, vol. 2071. Springer-Verlag, Berlin, Germany, 177--206.]] Google Scholar
- Wells, J. 1999. Typability and type checking in System F are equivalent and undecidable. Ann. Pure Appl. Logic 98, 1--3 (June), 111--156.]]Google Scholar
- Wells, J., Dimock, A., Muller, R., and Turbak, F. 2002. A calculus with polymorphic and polyvariant flow types. J. Funct. Programm. 12, 3 (May), 183--227.]] Google Scholar
- Wright, A. and Felleisen, M. 1994. A syntactic approach to type soundness. Inform. Computat. 115, 1, 38--94.]] Google Scholar
- Xi, H. 2000. Imperative programming with dependent types. In Proceedings of the 15th IEEE Symposium on Logic in Computer Science (Santa Barbara, CA). 375--387.]] Google Scholar
Index Terms
Quantified types in an imperative language
Recommendations
Polymorphic type inference and abstract data types
Many statically typed programming languages provide an abstract data type construct, such as the module in Modula-2. However, in most of these languages, implementations of abstract data types are not first-class values. Thus, they cannot be assigned to ...
Sound and complete bidirectional typechecking for higher-rank polymorphism with existentials and indexed types
Bidirectional typechecking, in which terms either synthesize a type or are checked against a known type, has become popular for its applicability to a variety of type systems, its error reporting, and its ease of implementation. Following principles ...
An existential crisis resolved: type inference for first-class existential types
Despite the great success of inferring and programming with universal types, their dual—existential types—are much harder to work with. Existential types are useful in building abstract types, working with indexed types, and providing first-class ...






Comments