[r6rs-discuss] Compile-time detection of contract violations

Abdulaziz Ghuloum aghuloum at cs.indiana.edu
Wed Nov 1 03:29:57 EST 2006


On Nov 1, 2006, at 1:36 AM, Michael Sperber wrote:
> [...]
> In safe mode, it returns 1 by virtue of the following wording (Section
> 5.1):
>
>  Also, if the number of arguments provided in a procedure call does
>  not match any argument count specified for the called procedure, an
>  exception with condition type {\cf\&contract} must be raised.

> [...]
> In unsafe mode, all bets are off by virtue of the following wording
> (as an example) (Section 4.3):
>
>  In \textit{unsafe} code, implementations might not raise the
>  exceptions that are normally raised in those situations.

Let me state my understanding and please correct me if I'm wrong.

Calling a procedure with an incorrect number of arguments raises a
&contract condition.  Implementations, under safe mode, must trap
such condition and invoke the installed exception handler.  Under
unsafe mode, implementations can ignore this condition since
&contract is a subtype of &defect which is a subctype of
&violation, and as per Section 9.22, "an implementation is allowed
to ignore any requirements for raising an exception with condition
type &violation (or any of its subtypes)".  Is this correct?

Also, as far as errors (such as attempting to open a nonexistent
file) are concerned, implementations cannot ignore these errors
even under unsafe mode since such errors raise &error which is
*not* a subtype of &violation.  Is this also correct?

Thanks.

Aziz,,,




More information about the r6rs-discuss mailing list