Common use of Higher-Order Contracts Clause in Contracts

Higher-Order Contracts. ‌ The base contracts in Section 4.1 and Section 4.2 specify flat statements on primitive values that may be true or false depending on the subject values. Even though straightforward assertions of base contracts may also test properties on functions and objects, they are not expressive enough to state higher-order properties of functions and objects that cannot be checked immediately. For example, a contract should be able to express that a function plus maps two number values to a number value or that the access to the length property of an array object always returns a number value. Hence, higher-order contracts are needed to address first-class functions and other advanced abstractions. To this end, TreatJS provides several kinds of higher-order contracts. In general, a higher-order contract is a contract that takes one or more contracts for the domain of an operation and that returns a contract for the range of an operation.

Appears in 2 contracts

Sources: Dissertation, Dissertation