[racket-dev] Class contracts: opaque or transparent?
On Apr 27, 2012, at 5:55 PM, Asumu Takikawa wrote:
> You can write that, but the following isn't very useful:
> (and/c (class/c #:opaque [m (->m number? number?)])
> (class/c #:opaque [n (->m number? number?)]))
>
> Since the two class contracts both reject classes that the other would
> accept (unless `and/c` somehow merged the first-order checks of the
> two rather than checking both separately).
:-)
> It works if the two contracts mention exactly the same members.
That's the useless case.
So I guess we're really giving up something with opaque contracts.
Since you're the one who created most and you don't seem to mind
copying contracts, I am fine with opaqueness. I won't use it myself,
however, when I write contracts for classes. I have found the above
pattern too useful.
-- Matthias