Lazy Contract Checking for Immutable Data Structures

IMPLEMENTATION AND APPLICATION OF FUNCTIONAL LANGUAGES(2008)

引用 32|浏览0
暂无评分
摘要
Existing contract checkers for data structures force programmers to choose between poor alternatives. Contracts are either built into the functions that construct the data structure, meaning that each object can only be used with a single contract and that a data structure with an invariant cannot be viewed as a subtype of the data structure without the invariant (thus inhibiting abstraction) or contracts are checked eagerly when an operation on the data structure is invoked, meaning that many redundant checks are performed, potentially even changing the program's asymptotic complexity.We explore the idea of adding a small, controlled amount of laziness to contract checkers so that the contracts on a data structure are only checked as the program inspects the data structure. Unlike contracts on the constructors, our lazy contracts allow subtyping and thus preserve the potential for abstraction. Unlike eagerly-checked contracts, our contracts do not affect the asymptotic behavior of the program.This paper presents our implementation of these ideas, an optimization in our implementation, performance measurements, and a discussion of an extension to our implementation that admits more expressive contracts by loosening the strict asymptotic guarantees and only preserving the amortized asymptotic complexity.
更多
查看译文
关键词
immutable data structures,strict asymptotic guarantee,asymptotic behavior,lazy contract checking,lazy contract,amortized asymptotic complexity,asymptotic complexity,expressive contract,existing contract checker,eagerly-checked contract,data structures force programmer,data structure
AI 理解论文
溯源树
样例
生成溯源树,研究论文发展脉络
Chat Paper
正在生成论文摘要