Yes, the -> is fine. And, so is doing the same bounds check in my own procedure. I was surprised that the ->d was so much slower. I use contracts regularly and was trying to expand my usage of them.<br><br><div class="gmail_quote">
On Sat, Apr 11, 2009 at 12:46 PM, Robby Findler <span dir="ltr"><<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
->d is definitely substantially slower than the other because the<br>
wrappers are more complex. Are you finding the performance overhead of<br>
the ordinary -> acceptable?<br>
<br>
Robby<br>
<div><div></div><div class="h5"><br>
On Sat, Apr 11, 2009 at 1:17 PM, Doug Williams<br>
<<a href="mailto:m.douglas.williams@gmail.com">m.douglas.williams@gmail.com</a>> wrote:<br>
> I would like to use ->d to impose a precondition for a function. For<br>
> example:<br>
><br>
> (matrix-ref<br>
> (->d ((matrix matrix?)<br>
> (i (and/c exact-nonnegative-integer? (</c (matrix-rows matrix))))<br>
> (j (and/c exact-nonnegative-integer? (</c (matrix-cols matrix)))))<br>
> ()<br>
> (result any/c)))<br>
><br>
> or<br>
><br>
> (matrix-ref<br>
> (->d ((matrix matrix?)<br>
> (i exact-nonnegative-integer?)<br>
> (j exact-nonnegative-integer?))<br>
> ()<br>
> #:pre-cond (and (< i (matrix-rows matrix))<br>
> (< j (matrix-cols matrix)))<br>
> (result any/c)))<br>
><br>
> instead of just<br>
><br>
> (matrix-ref<br>
> (-> 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<br>
> in the matrix-ref code, but can't accept the performance hit. Any ideas?<br>
><br>
> Doug<br>
><br>
><br>
</div></div>> _________________________________________________<br>
> For list-related administrative tasks:<br>
> <a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
><br>
><br>
</blockquote></div><br>