My answers are: 1. There isn't, but I've been planning to do this as soon as I revisit define-struct/contract in the new chaperone/impersonator world.
2. It's doable, but hasn't been done yet. I'll try and keep this in mind when I revisit the things listed in 1. If I were to do it, I'd imagine it'd look something like: (define-struct/contract foo ([bar number?] [moo (bar) <contract using bar>]) #:mutable) (i.e. it'd use the ->i convention for listing other fields on which this one is dependent.) Stevie On Jan 7, 2011, at 12:16 PM, Robby Findler wrote: > I think that chaperones let us implement this contract, but I don't > think that you can actually do it yet in the contract library (because > of the dependency), but Stevie would know best. > > Robby > > On Fri, Jan 7, 2011 at 9:58 AM, Matthias Felleisen <matth...@ccs.neu.edu> > wrote: >> >> 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 >> >> _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev