Skip to main content

Exception Handlers as Extensible Cases

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 5356))

Abstract

Exceptions are an indispensable part of modern programming languages. They are, however, handled poorly, especially by higherorder languages such as Standard ML and Haskell: in both languages a well-typed program can unexpectedly fail due to an uncaught exception. In this paper, we propose a technique for type-safe exception handling. Our approach relies on representing exceptions as sums and assigning exception handlers polymorphic, extensible row types. Based on this representation, we describe an implicitly typed external language EL where well-typed programs do not raise any unhandled exceptions. EL relies on sums, extensible records, and polymorphism to represent exceptionhandling, and its type system is no more complicated than that for existing languages with polymorphic extensible records.

EL is translated into an internal language IL that is a variant of System F extended with extensible records. The translation performs a CPS transformation to represent exception handlers as continuations. It also relies on duality to transform sums into records. (The details for this translation are given in an accompanying technical report.)

We describe the implementation of a compiler for a concrete language based on EL. The compiler performs full type inference and translates EL-style source code to machine code. Type inference relieves the programmer from having to provide explicit exception annotations. We believe that this is the first practical proposal for integrating exceptions into the type system of a higher-order language.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Appel, A.W., MacQueen, D.B.: Standard ML of New Jersey. In: Third International Symp. on Prog. Lang. Implementation and Logic Programming, pp. 1–13 ( August 1991)

    Google Scholar 

  2. Benton, N., Buchlovsky, P.: Semantics of an effect analysis for exceptions. In: TLDI 2007, pp. 15–26. ACM, New York (2007)

    Google Scholar 

  3. Benton, N., Kennedy, A.: Exceptional syntax. J. Funct. Program. 11(4), 395–410 (2001)

    Article  MathSciNet  MATH  Google Scholar 

  4. Blume, M., Acar, U.A., Chae, W.: Extensible programming with first-class cases. In: ICFP 2006: Proceedings of the eleventh ACM SIGPLAN international conference on Functional programming, pp. 239–250. ACM, New York (2006)

    Chapter  Google Scholar 

  5. Blume, M., Acar, U.A., Chae, W.: Exception handlers as extensible cases. U.Chicago, Computer Sci. Tech. Report TR-2008-03 (February 2008)

    Google Scholar 

  6. Cardelli, L., Donahue, J., Glassman, L., Jordan, M., Kalsow, B., Nelson, G.: Modula-3 report. Technical Report Research Report 31, DEC SRC (1988)

    Google Scholar 

  7. Fähndrich, M., Foster, J., Cu, J., Aiken, A.: Tracking down exceptions in Standard ML programs. Technical Report CSD-98-996, UC Berkeley (February 1998)

    Google Scholar 

  8. Felleisen, M., Hieb, R.: A revised report on the syntactic theories of sequential control and state. Theoretical Computer Science 103(2), 235–271 (1992)

    Article  MathSciNet  MATH  Google Scholar 

  9. Gansner, E.R., Reppy, J.H.: The Standard ML Basis Library. Cambridge University Press, Cambridge (2002)

    Google Scholar 

  10. Gosling, J., Joy, B., Steele, G., Bracha, G.: Java Language Specification, 2nd edn. The Java Series. Addison Wesley, Reading (2000)

    MATH  Google Scholar 

  11. Guzmán, J., Suárez, A.: An extended type system for exceptions. In: ACM SIGPLAN Workshop on ML and its Applications (1994)

    Google Scholar 

  12. Henglein, F.: Type inference with polymorphic recursion. ACM Trans. Program. Lang. Syst. 15(2), 253–289 (1993)

    Article  Google Scholar 

  13. Leroy, X.: The Objective Caml System (1996), http://caml.inria.fr/ocaml

  14. Leroy, X., Pessaux, F.: Type-based analysis of uncaught exceptions. ACM Trans. Program. Lang. Syst. 22(2), 340–377 (2000)

    Article  Google Scholar 

  15. Lions, J.L.: Ariane 5, flight 501 failure, report by the inquiry board (1996), http://sunnyday.mit.edu/accidents/Ariane5accidentreport.html

  16. Liskov, B., Atkinson, R., Bloom, T., Moss, E., Schaffert, J.C., Scheifler, R., Snyder, A.: CLU Reference Manual. Springer, New York (1981)

    MATH  Google Scholar 

  17. Ohori, A.: A polymorphic record calculus and its compilation. ACM Trans. Program. Lang. Syst. 17(6), 844–895 (1995)

    Article  Google Scholar 

  18. Yi, K.: An abstract interpretation for estimating uncaught exceptions in Standard ML programs. Sci. Comput. Program. 31(1) (1998)

    Google Scholar 

  19. Yi, K., Ryu, S.: Towards a cost-effective estimation of uncaught exceptions in sml programs. In: Van Hentenryck, P. (ed.) SAS 1997. LNCS, vol. 1302, pp. 98–113. Springer, Heidelberg (1997)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2008 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Blume, M., Acar, U.A., Chae, W. (2008). Exception Handlers as Extensible Cases. In: Ramalingam, G. (eds) Programming Languages and Systems. APLAS 2008. Lecture Notes in Computer Science, vol 5356. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-89330-1_20

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-89330-1_20

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-89329-5

  • Online ISBN: 978-3-540-89330-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics