Contract systems have come to play a vital role in many aspects of software engineering. This has resulted in a wide variety of approaches to enforcing contracts-ranging from the straightforward pre-condition and post-condition checking of Eiffel to lazy, optional, and parallel enforcement strategies. Each of these approaches has its merits, but each has required ground-up development of an entire contract monitoring system. We present a unified approach to understanding this variety, while also opening the door to as-yet-undiscovered strategies. By observing that contracts are fundamentally about communication between a program and a monitor, we reframe contract checking as communication between concurrent processes. This brings out the underlying relations between widely studied enforcement strategies, including strict and lazy enforcement as well as concurrent approaches, including new contracts and strategies. We show how each of these can be embedded into a core calculus, and demonstrate a proof (via simulation) of correctness for one such encoding. Finally, we show that our approach suggests new monitoring approaches and contracts not previously expressible. Behavioral software contracts, originally introduced by Meyer (1992), have become an integral part of modern programming practice, where they are used to specify and ensure program correctness. In the first-order, functional setting, programmers write predicates (i.e., functions that take an input and return a Boolean value as a result) to check program properties at function boundaries: the pre-condition predicate is applied to the function input; the function is run on its input (if the pre-condition predicate holds); and the post-condition predicate is applied to the function result. If either predicate returns false, the program terminates with an error. Programming, however, is more complex: programs utilize higher order functions, effectul operations, massive data structures, lazy evaluation mechanisms, and more. This added complexity must be addressed by the contract system: for higher order functions, we must delay contract enforcement (Findler & Felleisen, 2002) ; effectful This research was funded by the National Science Foundation under grant numbers 1117635, 1217454, 1540276, 1518844, and the National Security Agency. https://www.cambridge.org/core/terms. https://doi
REF study a variety of contract enforcement strategies including eager and lazy, synchronous and parallel.
An extended account of contract monitoring strategies as patterns of communication
J. Funct. Program.
J. Funct. Program.
Computer Science