[plt-scheme] Questions about contracts

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon Apr 16 21:46:56 EDT 2007

1. I didn't look at the code.

2. I did look at the error message and it became clear from there  
that you MUST supply a mu-lambda.

3. You didn't (Zhu) and so the contract blew up on you.

4. To write the contract that you want, you may have to use arity  
though I don't know off-hand whether this is possible here.

Too busy to try. It still isn't a problem with the contract system.  
-- Matthias




On Apr 16, 2007, at 9:36 PM, Matthew Flatt wrote:

> At Mon, 16 Apr 2007 17:16:20 -0600, "Chongkai Zhu" wrote:
>> Let's say the SVN  Revision 3591 of SRFI 63
>> (http://svn.plt-
>> scheme.org/view/trunk/collects/srfi/63/63.ss? 
>> revision=3591&pathrev=5900).
>>
>> The contract of make-shared-array is:
>>
>>    (make-shared-array
>>     (->r ((array array?)
>>           (mapper (->* () (listof natural-number/c)
>>                        ((listof natural-number/c)))))
>>          indices (listof natural-number/c)
>>          array?))
>>
>> which looks fine.
>
> Not to me!
>
> The above contract (and the error message) says that the second
> argument to `make-shared-array' must be a function that accepts any
> number of arguments. Such a contract empowers `make-shared-array' to
> call the given function with, say, 4 arguments, then 0 arguments, then
> 2 arguments, all before returning --- independent of the other
> arguments to `make-shared-array'.
>
> The actual `make-shared-array', however, merely expects the  
> function to
> accept the same number of arguments as supplied indices. That's very
> different than requiring the function to accept any number of
> arguments.
>
> I must admit that I don't know offhand how to write the actual  
> contract
> down; that's probably my lack of expertise with the contract library.
> Meanwhile, the only bug I see is that the contract above is way too
> strict. I don't see a bug in the implementation of contracts.
>
> Matthew
>



Posted on the users mailing list.