[plt-scheme] Questions about contracts

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Apr 16 22:36:12 EDT 2007

The contract system is correct, Chongkai.

You wrote that your make-shared-array's second argument must be a
function accepts an arbitrary number of arguments. You supplied a
function that only takes one argument.

Think of it from the perspective of make-shared-array. The contract
should entitle it to apply mapper to 3 arguments, but your function
does not accept 3 arguments.

Robby

On 4/16/07, Chongkai Zhu <czhu at cs.utah.edu> 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.
>
> But if you run it:
>
> > (define fred (make-array '#(#f) 8 8))
> > (define freds-diagonal
>     (make-shared-array fred (lambda (i) (list i i)) 8))
> . 6:5: top-level broke the contract
>   (->r ((array ...) (mapper ...)) indices ... ...)
> on make-shared-array; expected a procedure that accepts 0 arguments and any
> number of arguments larger than 0, given: #<procedure>
> >
>
> Chongkai
>
> ----- Original Message -----
> From: "Matthias Felleisen" <matthias at ccs.neu.edu>
> To: "Chongkai Zhu" <czhu at cs.utah.edu>
> Cc: <plt-scheme at list.cs.brown.edu>
> Sent: Monday, April 16, 2007 5:06 PM
> Subject: Re: [plt-scheme] Questions about contracts
>
>
> > Can you provide an example? A statement like this is rather, eh,
> >  strange. -- Matthias
> >
> >
> >
> >
> > On Apr 16, 2007, at 7:01 PM, Chongkai Zhu wrote:
> >
> >>
> >> ----- Original Message ----- From: "Matthias Felleisen"
> >> <matthias at ccs.neu.edu>
> >> To: "Henk Boom" <lunarc.lists at gmail.com>
> >> Cc: <plt-scheme at list.cs.brown.edu>
> >> Sent: Monday, April 16, 2007 4:55 PM
> >> Subject: Re: [plt-scheme] Questions about contracts
> >>
> >>
> >>>  (2) unlike Eiffel's, our contract system copes with higher-order
> >>> functions.
> >>
> >> Sorry, but I tried our contract system with higher-order functions
> >> recently, and doesn't feel that it works in general cases.
> >>
> >> Chongkai
> >>
> >>
> >
> >
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.