I would like to use -&gt;d to impose a precondition for a function.  For example:<br><br> (matrix-ref<br>  (-&gt;d ((matrix matrix?)<br>        (i (and/c exact-nonnegative-integer? (&lt;/c (matrix-rows matrix))))<br>        (j (and/c exact-nonnegative-integer? (&lt;/c (matrix-cols matrix)))))<br>
       ()<br>       (result any/c)))<br><br>or<br><br> (matrix-ref<br>  (-&gt;d ((matrix matrix?)<br>        (i exact-nonnegative-integer?)<br>        (j exact-nonnegative-integer?))<br>       ()<br>       #:pre-cond (and (&lt; i (matrix-rows matrix))<br>
                       (&lt; j (matrix-cols matrix)))<br>       (result any/c)))<br><br>instead of just<br><br> (matrix-ref<br>  (-&gt; matrix? exact-nonnegative-integer? exact-nonnegative-integer? any/c))<br><br>The first two do work, but are really, really slow.<br>
<br>I like having the bounds check in the contract (as opposed to bounds check in the matrix-ref code, but can&#39;t accept the performance hit. Any ideas?<br><br>Doug<br><br>