Errors as Data Values as the Language Default

Tero Hasu and Magne Haveraaen
Bergen Language Design Laboratory
Department of Informatics
University of Bergen, Norway

Abstract

A “thrown” exception is a non-local side effect that complicates static reasoning about code. In some programs errors are instead propagated as ordinary values. Such propagation is sometimes done in monadic style, and some languages include syntactic conveniences for writing expressions in that style. We sketch a language-based failure management approach in which error-monad-resembling transparent error value propagation is made the language default. The approach accommodates language designs with all-referentially-transparent expressions, and syntactic conveniences resembling those of traditional exception mechanisms. Our proof-of-concept implementation of the approach is furthermore capable of automatically checking data invariants and function pre- and post-conditions, recording a trace of the failed or unevaluatable expressions caused by an error, and in some cases retaining “bad” values for potential use in recovering from an error.

BibTeX

@inproceedings{hasu-haveraaen-2015-errors,
  author =       {Tero Hasu and Magne Haveraaen},
  title =        {Errors as Data Values as the Language Default},
  booktitle =    {Proceedings of the 27th Nordic Workshop on
                  Programming Theory (NWPT 2015)},
  year =         2015,
  month =        oct,
  location =     {Reykjavik, Iceland}
}

Scribble

(define hasu-haveraaen-2015-errors
  (make-bib
   #:title "Errors as Data Values as the Language Default"
   #:author (authors "Tero Hasu" "Magne Haveraaen")
   #:date "2015"
   #:location (proceedings-location
     "Nordic Wksp. Programming Theory")))

Publication Details