Wishlist: a way to define function types as contracts (researchy)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Incomplete
|
Undecided
|
Unassigned |
Bug Description
The standard CL FTYPE declaration is a description of usage: in all calls to the function, the arguments will have these types and the return value(s) this type.
It would be interesting to instead have a contract-like declaration for types of functions: rules of the form IF the arguments have these types, THEN the value returned has this type. This could then be hooked into type propagation by checking, at each call, which of the rules have preconditions that are definitely true.
Other declarations of function behavior that could be useful: that a function has no side effects, the set of conditions a function might signal, the set of special variables a function may depend on, the set of special variables a function might modify, and catch values the function could throw to (and the types of the values thrown.)
Internally this exists. Anything for external usage should probably be proposed and discussed on the mailing list. Nobody's looking at it otherwise.