[plt-scheme] improving arity checks in contracts

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Jul 14 17:26:44 EDT 2006

The error is detected and even at the right place, but without the  
right blame. I've resisted supporting this in the contract library  
because the performance implications seem pretty tremendous. But  
you're not the first to ask, so maybe I'll work harder on it now.

Robby

On Jul 14, 2006, at 4:01 PM, Danny Yoo wrote:

> Hi everyone,
>
>
> I've been chasing down a bug in my code that had to do with  
> breaking a contract, but the contract system didn't help too much  
> in finding the proper party to blame.  Here's an example where the  
> contracts don't properly blame the provider:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> (module foo mzscheme
>     (require (lib "contract.ss"))
>     (provide/contract (q/r (number? number? . -> . number?)))
>     (define (q/r a b)
>       (values (quotient a b) (remainder a b))))
>> (require foo)
>> (q/r 3 4)
> context expected 1 value, received 2 values: 0 3
>
>  === context ===
> repl-loop
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> The bug in my code here is obvious: the contract is wrong.  But the  
> error message that comes out could be a lot more helpful.  I hope  
> contract.ss can be easily amended to check this; I'm starting to  
> heavily use let-values, and I'm making a lot of mistakes that the  
> contract system should blame me with... *grin*
>
>
> Thanks!
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



Posted on the users mailing list.