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.
--
j
tangentially related (i.e., having a single point in common):
http://jorendorff.blogspot.com/2006/03/domain-errors-or-stupid-compiler.html
Received on Tue Oct 24 2006 - 10:20:53 UTC