5.7 Object and Class Contracts
(object-contract member-spec ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Produces a contract for an object.
Each of the contracts for a method has the same semantics as the corresponding function contract, but the syntax of the method contract must be written directly in the body of the object-contract – much like the way that methods in class definitions use the same syntax as regular function definitions, but cannot be arbitrary procedures. The only exception is that ->d contracts implicitly bind this to the object itself.
A function contract that recognizes mixins. It guarantees that the input to the function is a class and the result of the function is a subclass of the input.
(make-mixin-contract type ) → contract? |
type : (or/c class? interface?) |
Produces a function contract that guarantees the input to the function is a class that implements/subclasses each type, and that the result of the function is a subclass of the input.
(is-a?/c type) → flat-contract? |
type : (or/c class? interface?) |
Accepts a class or interface and returns a flat contract that recognizes objects that instantiate the class/interface.
(implementation?/c interface) → flat-contract? |
interface : interface? |
Returns a flat contract that recognizes classes that implement interface.
(subclass?/c class) → flat-contract? |
class : class? |
Returns a flat-contract that recognizes classes that are subclasses of class.