[racket] Why this contract violation behaviour?

From: Galler (lzgaller at optonline.net)
Date: Fri Nov 16 19:52:50 EST 2012

> 
> 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




Posted on the users mailing list.