本章提供了对 Racket contract 系统的简要介绍。
(part ("(lib scribblings/reference/reference.scrbl)" "contracts")) in (part ("(lib scribblings/reference/reference.scrbl)" "top")) provides more on contracts.
7.1 Contracts and Boundaries
7.1.1 Contract Violations
7.1.2 Experimenting with Contracts and Modules
7.1.3 Experimenting with Nested Contract Boundaries
7.2 Simple Contracts on Functions
7.2.1 Styles of ->
7.2.2 Using define/contract and ->
7.2.3 any and any/c
7.2.4 自定义 Contract
7.2.5 高阶函数上的 Contract
7.2.6 包含 “???” 的 Contract 消息
7.2.7 剖析 contract 错误消息
7.3 Contracts on Functions in General
7.3.1 Optional Arguments
7.3.2 剩余参数
7.3.3 关键字参数
7.3.4 Optional 关键字参数
7.3.5 case-lambda 的契约
7.3.6 参数与结果之间的依赖关系
7.3.7 检查状态变更
7.3.8 多返回值
7.3.9 固定但静态未知的元数
7.4 Contracts: A Thorough Example
7.5 Contracts on Structures
7.5.1 对特定值的保证
7.5.2 对所有值的保证
7.5.3 检查数据结构的属性
7.6 Abstract Contracts using #:exists and #:∃
7.7 Additional Examples
7.7.1 A Customer-Manager Component
7.7.2 A Parameteric (Simple) Stack
7.7.3 A Dictionary
7.7.4 A Queue
7.8 Building New Contracts
7.8.1 Contract Struct Properties
7.8.2 With all the Bells and Whistles
7.9 Gotchas
7.9.1 Contracts 与 eq?
7.9.2 Contract 边界与 define/contract
7.9.3 Exists Contract 与谓词
7.9.4 定义递归 Contract
7.9.5 混合使用 set! 与 contract-out