Class invariants are both a core concept of object-oriented programming and the source of the two key open OO verification problems: furtive access (from callbacks) and reference leak. Existing approaches force on programmers an unacceptable annotation burden. This article explains invariants and solves both problems modularly through the O-rule, defining fundamental OO semantics, and the inhibition rule, using information hiding to remove harmful reference leaks. It also introduces the concept of "object tribe" as a basis for other possible approaches. For all readers: this article is long because it includes a tutorial, covers many examples and dispels misconceptions. To understand the key ideas and results, however, the first two pages suffice. For non-experts in verification: all concepts are explained; anyone with a basic understanding of object-oriented programming can understand the discussion. For experts: the main limitation of this work is that it is a paper proposal (no soundness proof, no implementation). It addresses, however, the known problems with class invariants, solving such examples as linked lists and Observer, through a simple theory and without any of the following: ownership; separation logic; universe types; object wrapping and unwrapping; semantic collaboration, observer specifications; history invariants; "inc" and "coop" constructs; friendship construct; non-modular reasoning. More generally, it involves no new language construct and no new programmer annotations.
翻译:类变数既是一个面向目标的编程的核心概念,也是两个关键的开放 OOO 核查问题的来源: 隐性访问( 从回调) 和 参考漏漏 。 现有方法迫使程序员使用现有方法 是一种不可接受的批注负担 。 本条通过 Or 规则解释变数, 以模块方式解决这两个问题, 界定基本 OO 语义, 以及抑制规则, 利用信息隐藏来消除有害的参考泄漏 。 它还将“ 对象部落” 的概念作为其他可能办法的基础 。 对于所有读者来说 : 本条很长, 因为它包括一个教义, 包含许多例子, 并消除错误观念 。 但是, 要理解关键的想法和结果, 前两页就足够了 。 对于非核查专家来说, 所有概念都得到了解释; 任何对面向目标的编程有基本理解的人都可以理解讨论 。 对于专家来说, 这项工作的主要限制是它是一个纸质建议( 没有正确性证据, 没有执行 ) 。 但是, 它解决了类变数的已知问题,, 解决诸如关联列表和观察者之类的示例,,, 通过简单的理论和没有以下任何推理; 的推理; 更多的逻辑 解释性 ; 。