Contracts question on structs

Chris GauthierDickey <[email protected]>
Newsgroups gmane.comp.lang.racket.user,gmane.lisp.scheme.plt
Message-ID <CAArNTODLb=nEsXRPwP=F1Fq4rFe6TB3X8Cx2DY8FrvDiQHYLbA@mail.gmail.com>
I'm wondering if it's possible to have a contract for a struct that only
allows certain kinds of initializations. For example, I have this:

(provide (contract-out
          [struct Result ((name (or/c Temp? Label?)) (global? boolean?)
(value (or/c VarValue? #f)))]))

But it's too general. What I'd really like to have is a contract that
combines them like an or/c (I can see what this would cause problems, just
wondering if there's a clever way around it):
(provide (contract-out
          [or/c (struct Result ((name Temp?) (global? #f) (value (or/c
VarValue? #f))))
                (struct Result ((name Label?) (global? boolean?) (value
(or/c (VarValue #f)))))]))

In this case, if name is Temp? then global? has to be #f. If name is Label?
then global? can be #t or #f. I'd like to use struct cause it provides all
the contracts for accessors and such. Note, I can use a #:guard on the
struct, but wondered if it was possible to do something along these lines
with a contract.

Thanks!
Chris

-- 
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.