[racket] image equality and evaluators

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Feb 9 22:13:40 EST 2012

The structs that are used to represent images are generative and
you're getting two different versions of them, one inside the sandbox
and one outside.

You could do the equality comparison inside the sandbox (the notion of
booleans is shared between the sandbox and the outside, unlike
images). You could set up the sandbox yourself to share the notion of
images, but that might get complex (fiddling with namespaces). You can
also turn images into bitmaps and those into bytes which can be shared
across the boundary of a sandbox, using the file/convertible library


Which version are you using? I get this program:

(make-evaluator '(special beginner) #:requires '(2htdp/image))


module: identifier already imported from a different source in:
  (lib "htdp-beginner.rkt" "lang")

which I think is probably an issue somehow with what '(special
beginner) means and its interaction with 2htdp/image.

On Thu, Feb 9, 2012 at 8:40 PM, Jordan Johnson <jmj at fellowhuman.com> wrote:
> Hi all,
> Definitions:
>> #lang racket
>> (require racket/sandbox lang/imageeq)
>> (define ev
>>   (make-evaluator '(special beginner)
>>                   #:requires '(2htdp/image)))
> Interactions:
>> > (image? (ev '(rectangle 2 2 'solid 'blue)))
>> #f
>> > (image=? (ev '(rectangle 2 2 'solid 'blue))
>>            (ev '(rectangle 2 2 'solid 'blue)))
>> image=?: expects type <image> as 1st argument, given: (object:image% ... )
>> ... [etc., redacted]
> But the REPL renders (ev '(rectangle 2 2 'solid 'blue))) as a picture of a
> tiny rectangle, as I would expect.
> How is the above exposing the difference between image=?'s perception of an
> image, and the object implementing the image?
> And, more importantly, is there a way to make (meaningful) image comparisons
> across the boundary imposed by the sandbox?
> Thanks,
> jmj
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

Posted on the users mailing list.