[racket] Weird class/c behavior
On Aug 29, 2010, at 11:25 PM, Eric Dobson wrote:
> I am using class/c and am seeing behavior that I do not understand. I
> have two different contracts, one which has an extra contract on an
> unused initializer argument. The interesting behavior is that the two
> different contracts blame different sides for the same error. Can
> someone explain why this is?
I can show what is happening to cause the different blame behavior. However, I'm certain it's due to an underlying bug, so I'm about to investigate why it's happening, as it shouldn't.
If you replace the target1%/c and target2%/c contracts with:
(define target1%/c
(class/c
(init (build (-> (and/c (lambda (x) (printf "in init\n") #t)
(listof string?)))))
(build (->m (-> (and/c (lambda (x) (printf "in method\n") #t)
(listof string?)))))))
(define target2%/c
(class/c
(init (build (-> (and/c (lambda (x) (printf "in init\n") #t)
(listof string?))))
(depends any/c))
(build (->m (-> (and/c (lambda (x) (printf "in method\n") #t)
(listof string?)))))))
You'll notice that "in init" is printed when the contract for target1% fails, but "in method" is printed when the contract for target2% fails. That is, the init contract is not getting triggered appropriately for target2%.
I'll update further once I discover why this is.
Stevie