Unfortunately, this is just a fact of life with the current strategy
we have for implementing parametric contracts. Without changing the
basic idea behind the way parametric contracts work it would, IMO, be
an improvement for the use of p? in the outside to raise an error
(since you tried to learn something about those "a" values that you
are not supposed to know), but I don't know how to do that without too
high of a runtime cost, which is why things like equal? just return #f
instead of raising errors.

But maybe in this specific case (equality and hashing), there could be
an error inserted without hurting the performance of unrelated parts
of the system. (Backwards compatibility seems like an issue, tho.)

If you're interested and want to try the experiment, I'd be curious
what turns up.

Robby


On Wed, Mar 23, 2016 at 10:43 AM, Phil Nguyen <philnguyen0...@gmail.com> wrote:
> In the following program, `(p? 1 1)` returns `#t` or `#f` depending on `p?` 
> being called from the same or different module:
>
> #lang racket
>
> (module m racket
>   (provide
>     (contract-out
>       [p? (parametric->/c (a) (a a . -> . boolean?))]))
>   (define p? equal?)
>   (p? 1 1))
>
> (require 'm)
> (p? 1 1)
>
> Module `m` is wrong in the first place for comparing 2 sealed objects, but 
> here we don't get an error. Is it practical to make `equal?` aware of 
> parametric contracts?
>
> This bit me in practice when I used a hashtable (which had an implicit 
> `equal?`). The worse part was that tests passed because they were in the same 
> module, and I only got unexpected behavior from outside.
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to