[plt-scheme] Is there a general overview of contracts somewhere?
Matthias Felleisen <matthias at ccs.neu.edu> writes:
>> Yes, it's pretty clear that CL implementors typically *use* type specs as
>> pragmas for efficiency; however, the standard *does* say that contexts that
>> violate type specs are absolutely in error, but conforming implementations
>> are not *required* to detect the errors. Thus there could be high-quality
>> implementations in which type specs are taken seriously.
>
> Do you know of one? -- Matthias
How about sbcl?
<http://sbcl-internals.cliki.net/Declarations%20are%20Assertions>
Cmucl will also issue compile time warnings in situations like this:
(defun f (x)
(declare (type (mod 10) x))
(+ x 1))
(defun g (a)
(declare (type (mod 10) a))
(f (+ 12 a)))
gives
; Warning: Result is a (INTEGER 12 21), not a (VALUES &OPTIONAL (MOD 10) &REST T).
'as