[racket-dev] Class contracts: opaque or transparent?

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Fri Apr 27 14:27:32 EDT 2012

On 2012-04-27 13:17:36 -0500, Robby Findler wrote:
> Specifically, it seems like I can add the contract
> (unconstrained-domain-> any) to each method to get it to be opaque
> without actually contributing anything of value.
> [...]
> Or is there something else going on there that I'm missing?

The primary reason that I added opaque contracts is that they are needed
for Typed Racket's eventual class/object support.

A secondary reason is for enforcing contract coverage. You're right
though: you could get around this by writing a loose contract or by
only specifying the name.[1] The intention is that the contract error
would encourage people to write useful contracts (my mistake for saying
"force"---it doesn't quite do that) rather than just bypass it.

[1]: e.g., (class/c #:opaque m) will allow
     (class object% (super-new) (define/public (m) ...))


Posted on the dev mailing list.