[racket] comparing structure types through contracts
This is fixed now.
Thanks,
Robby
On Tue, Feb 7, 2012 at 1:19 AM, John Clements <clements at brinckerhoff.org> wrote:
> I'm working with Dave Herman's JavaScript package. I've found a problem and a workaround, but I want to make sure there's not an easier workaround before I convert a bunch of code. The following program illustrates the issue:
>
> #lang racket/load
>
> (module a racket
>
> ;; this formulation "works" (prints #t):
> (define-struct/contract s ((a number?) (b number?)) #:transparent)
> (provide (struct-out s))
>
> ;; this formulation does not work (prints #f):
> #;(define-struct s (a b) #:transparent)
>
> #;(provide/contract [struct s ([a number?]
> [b number?])]
> #;(struct-out s)))
>
> (module b racket
> (require 'a)
> (define-values (type _) (struct-info (make-s 3 4)))
> (printf "type: ~s\n" type)
> (printf "eq? ~s\n"
> (eq? type
> struct:s)))
>
> (require 'b)
>
>
> The problem is that when a structure is defined using define-struct and then a contract is provided at the boundary, the structure type returned by struct-info doesn't compare to the exported struct's value using eq?. As the code illustrates, I can work around this by pushing the contract down into the definition of the structure itself.
>
> Before I change many pairs of structure-definitions & contracts, is there some other simpler way to make this code "work"--that is, print #t?
>
> Thanks!
>
> John
>
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>