A study of evaluation order semantics in expressions with side effects

The presence of side effects in even a very simple language of expressions gives rise to a number of semantic questions. The issue of evaluation order becomes a crucial one and, unless a specific order is enforced, the language becomes non-deterministic. In this paper we study the denotational semantics of such a language under a variety of possible evaluation strategies, from simpler to more complex, concluding with unspecified evaluation order, unspecified order of side effects and the mechanism of sequence points that is particular to the ANSI C programming language. In doing so, we adopt a dialect of Haskell as a metalanguage, instead of mathematical notation, and use monads and monad transformers to improve modularity. In this way, only small modifications are required for each transition. The result is a better understanding of different evaluation strategies and a unified way of specifying their semantics. Furthermore, a significant step is achieved towards a complete and accurate semantics for ANSI C.

[1]  Hans-Juergen Boehm A logic for expressions with side-effects , 1982, POPL '82.

[2]  Philip Wadler,et al.  The essence of functional programming , 1992, POPL '92.

[3]  Mark P. Jones A system of constructor classes: overloading and implicit higher-order polymorphism , 1993, FPCA '93.

[4]  Simon Peyton Jones,et al.  Type classes: an exploration of the design space , 1997 .

[5]  John Hughes,et al.  Report on the Programming Language Haskell 98 , 1999 .

[6]  Nikolaos Papaspyrou,et al.  A Formal Semantics for the C Programming Language , 2000 .

[7]  Mark P. Jones,et al.  The implementation of the Gofer functional programming system , 1994 .

[8]  Ravi Sethi,et al.  A case study in specifying the semantics of a programming language , 1980, POPL '80.

[9]  Peter D. Mosses,et al.  Denotational semantics , 1995, LICS 1995.

[10]  Phillip J. Windley,et al.  Inference Rules for Programming Languages with Side Effects in Expressions , 1996, TPHOLs.

[11]  Erik P. de Vink,et al.  Control flow semantics , 1996 .

[12]  Michael Norrish An abstract dynamic semantics for C , 1997 .

[13]  David A. Espinosa Semantic Lego , 1995 .

[14]  S. Purushothaman Iyer,et al.  A compositional analysis of evaluation-order and its application , 1990, LISP and Functional Programming.

[15]  Paul Hudak,et al.  Monad transformers and modular interpreters , 1995, POPL '95.

[16]  Ralf Hinze,et al.  Haskell 98 — A Non−strict‚ Purely Functional Language , 1999 .

[17]  Paul Hudak,et al.  Modular monadic semantics and compilation , 1998 .

[18]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

[19]  Adrienne G. Bloss Path analysis and the optimization of nonstrict functional languages , 1994, TOPL.

[20]  Yuri Gurevich,et al.  The Semantics of the C Programming Language , 1992, CSL.