<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16587" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY
style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space"
bgColor=#ffffff>
<DIV><FONT face=Arial size=2>(case (-> ..) (-> ..)) works perfect. Why did
I miss that? It is in the docs, although at the very end of the
chapter.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I did already go along the line of your
example with ->*, but it is less restrictive than I want.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks,</FONT></DIV>
<DIV><FONT face=Arial size=2>Jos</FONT></DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=d.j.gurnell@gmail.com href="mailto:d.j.gurnell@gmail.com">Dave
Gurnell</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=plt-scheme@list.cs.brown.edu
href="mailto:plt-scheme@list.cs.brown.edu">plt-scheme@list.cs.brown.edu</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, February 06, 2008 2:04
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [plt-scheme] contract
question</DIV>
<DIV><BR></DIV>I'm not sure why you can't use or/c (see below), but you should
be able to use ->* or case->:
<DIV><BR class=webkit-block-placeholder></DIV>
<DIV>
<DIV><SPAN class=Apple-style-span style="COLOR: rgb(0,0,0)">
<DIV><FONT size=+0><FONT class=Apple-style-span face=Monaco size=3><SPAN
class=Apple-style-span style="FONT-SIZE: 12px"> (define
(example a (b #f))<BR> (if b (+ a b)
(void)))</SPAN></FONT></FONT></DIV>
<DIV><FONT class=Apple-style-span face=Monaco size=3><SPAN
class=Apple-style-span style="FONT-SIZE: 12px"><BR
class=webkit-block-placeholder></SPAN></FONT></DIV>->* specifies contracts
for variable arity procedures:<BR>
<DIV><BR class=webkit-block-placeholder></DIV>
<DIV><FONT class=Apple-style-span face=Monaco size=3><SPAN
class=Apple-style-span style="FONT-SIZE: 12px">
(provide/contract</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span face=Monaco size=3><SPAN
class=Apple-style-span style="FONT-SIZE: 12px"> (example
(->* (number?) (number?) (or/c number? void?))))</SPAN></FONT></DIV></SPAN>
<DIV><BR class=webkit-block-placeholder></DIV>case-> is intended for
contracts on case-lambdas, but it should work okay here:</DIV>
<DIV><BR></DIV>
<DIV>
<DIV><FONT class=Apple-style-span face=Monaco size=3><SPAN
class=Apple-style-span style="FONT-SIZE: 12px">
(provide/contract</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span face=Monaco size=3><SPAN
class=Apple-style-span style="FONT-SIZE: 12px"> (example
(case-> (-> number? number? number?)</SPAN></FONT></DIV>
<DIV><FONT class=Apple-style-span face=Monaco size=3><SPAN
class=Apple-style-span style="FONT-SIZE: 12px">
(-> number?
void?))))</SPAN></FONT></DIV>
<DIV><BR></DIV>
<DIV>I thought or/c could only be used on value contracts but the
documentation suggests otherwise.</DIV>
<DIV><BR class=webkit-block-placeholder></DIV></DIV>
<DIV>
<DIV>
<DIV>
<DIV>
<DIV>
<DIV>Cheers,</DIV>
<DIV><BR class=webkit-block-placeholder></DIV>
<DIV>-- Dave</DIV>
<DIV><BR></DIV>
<BLOCKQUOTE type="cite"><SPAN class=Apple-style-span
style="WORD-SPACING: 0px; FONT: 13px 'Lucida Grande'; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0">
<DIV bgcolor="#ffffff">
<DIV><FONT face=Arial size=2>Finally I decided to try contracts. I
tried:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>#| require one or two numbers<BR>
promise to return a number if two numbers are given<BR> promise
void if one number is given |#</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>#lang scheme</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>(provide/contract<BR> (example<BR>
(or/c<BR> (-> number? number? number?)<BR> (->
number? void?))))</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>(define (example a (b #f))<BR> (if b (+ a
b) (void)))</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This compiles, but it wont run:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Welcome to DrScheme, version
3.99.0.10-svn4feb2008 [3m].<BR>Language: Module custom.<BR>or/c: two
arguments, (-> number? void?) and (-> number? number? number?), might
both match #<procedure:example></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Why? What is wrong in my contract? May be I am
wanting an impossible contract?</FONT></DIV>
<DIV><FONT face=Arial size=2>or/c repeats exactly what I want, but does not
accept it.</FONT></DIV>
<DIV><FONT face=Arial size=2>I think I am missing something fundamental, but
I can't find an answer in the docs.</FONT></DIV>
<DIV><FONT face=Arial size=2>Thanks,<SPAN
class=Apple-converted-space> </SPAN></FONT><FONT face=Arial size=2>Jos
Koot</FONT></DIV>_________________________________________________<BR> For
list-related administrative tasks:<BR> <A
href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</A><BR></DIV></SPAN></BLOCKQUOTE></DIV><BR></DIV></DIV></DIV></DIV></DIV>
<P>
<HR>
<P></P>_________________________________________________<BR> For
list-related administrative tasks:<BR>
http://list.cs.brown.edu/mailman/listinfo/plt-scheme<BR></BLOCKQUOTE></BODY></HTML>