[racket-dev] struct contracts

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Jan 7 10:58:15 EST 2011

1. Is there a struct/contract? 

2. I would like to write something like this: 

(define-struct/contract foo ([bar number?][moo (->i (*bar*) ([x (and/c number? (>/c bar))]) (r number?))]) #:mutable)

The *bar* is a 'reference' to the bar field, that is, I want to have a function contract for a structure field that depends on the (current) value of a (mutable) field of the same structure. 

Is this doable? 

2a. I considered writing a function foo-init that mimics this, but I can't write this either. 

Q: Is my only choice to write a class with a contract? 

-- Matthias

Posted on the dev mailing list.