一句话:将 chaperone 契约扩展到会话,在高阶语言中建立动态监控语义与 blame 定理,并给出 OCaml 实现。
论文研究并发程序中的会话契约监控问题。会话端点上的消息种类、方向与属性会随会话推进而变化,传统函数/对象契约无法描述这种动态行为,因此需要能随会话演化的契约。作者将用于可变对象的 chaperone 契约推广到高阶会话,在一个带会话的高阶语言中形式化契约监控,给出“正确模块”的刻画,即模块始终遵守其使用会话的契约,并证明 blame 定理以定位违约方。基于该演算,作者实现了一个轻量级 OCaml 模块,利用现成 OCaml 支持静态会话类型检查与动态契约监控。
Contracts have proved to be an effective mechanism that helps developers in identifying those modules of a program that violate the contracts of the functions and objects they use. In recent years, sessions have established as a key mechanism for realizing inter-module communications in concurrent programs. Just like values flow into or out of a function or object, messages are sent on, and received from, a session endpoint. Unlike conventional functions and objects, however, the kind, direction, and properties of messages exchanged in a session may vary over time, as the session progresses. This feature of sessions calls for contracts that evolve along with the session they describe. In this work, we extend to sessions the notion of chaperone contract (roughly, a contract that applies to a mutable object) and investigate the ramifications of contract monitoring in a higher-order language that features sessions. We give a characterization of correct module, one that honors the contracts of the sessions it uses, and prove a blame theorem. Guided by the calculus, we describe a lightweight implementation of monitored sessions as an OCaml module with which programmers can benefit from static session type checking and dynamic contract monitoring using an off-the-shelf version of OCaml.