[r6rs-discuss] Compile-time detection of contract violations
jason.orendorff at gmail.com
Tue Oct 24 10:20:53 EDT 2006
Many places in R5.91RS specify &contract exceptions to be raised for
various errors. For example, (cons 1 2 3) causes a &contract
exception (too many arguments).
In R5RS, the spec just said "it is an error". Implementations were
allowed to detect this at compile time, at run time, or not at all.
R5.91RS rejects the "not at all" option, except under (declare
unsafe). So far, so good.
What about at compile time? Does R5.91RS allow an implementation to
detect a contract violation at compile time and reject the program? I
couldn't find any such wording. I think this should be allowed.
Opinions will differ on whether this behavior is helpful, and no
compiler can detect all contract violations at compile time. Still,
any optimizing compiler will be able to detect some of these, and
treating them as errors seems reasonable to me.
tangentially related (i.e., having a single point in common):
More information about the r6rs-discuss