[racket-dev] struct contracts

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Fri Jan 7 12:16:51 EST 2011

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


Posted on the dev mailing list.