Contracts really are like business contracts. They are between two distinct 
parties; they are not by a party on itself. 

On occasion, you really do want to wish to break the contract inside a module. 
This is well-known in the OO world, and it is often called the re-entrance 
problem. Say you want a balanced tree object. Imagine it has a method with a 
contract that requires 'balanced'ness but is also called internally. Perhaps 
you don't need/wish to balance for internal calls. So you do -- and you don't 
get caught. 

Contracts impose a run-time cost. To make the cost reasonable, we trust the 
programmer and we let the programmer know that we trust him. 









On Nov 16, 2012, at 7:52 PM, Galler wrote:

>> 
>> Even if you use define/contract, you may violate the contract on recursive
> calls. This is intentional. 
>> 
> 
> Thanks.
> 
> I hadn't run into that behavior before and wasn't aware. 
> 
> Could you possibly elaborate on the thinking wrt this design choice?
> 
> (define/contract (my-natural-number n)
>  (-> exact-positive-integer? any/c)
>  (print n) (newline)
>  (my-natural-number (sub1 n)))
> 
> (my-natural-number 1)
> 1
> 0
> -1
> -2
> -3
> -4
> 
> 
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Attachment: smime.p7s
Description: S/MIME cryptographic signature

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to