[racket] image equality and evaluators
Nice - this is useful to me too, thanks very much. FWIW, instead of
make-base-namespace
I had to use
make-gui-namespace
to avoid a "cannot instantiate `racket/gui/base' a second time in the
same process" error.
On Thu, Feb 9, 2012 at 10:15 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> On Thu, Feb 9, 2012 at 9:12 PM, Eli Barzilay <eli at barzilay.org> wrote:
>> The other way is what gets you what you want: you need to use
>> `sandbox-namespace-specs' to make the sandbox share an instance of the
>> necessary modules between your own code and the sandbox, so that
>> structs in the sandbox are the same type as your own. Here's a quick
>> example:
>>
>> #lang racket
>> (require racket/sandbox 2htdp/image)
>> (define ev
>> (parameterize ([sandbox-namespace-specs
>> (list make-base-namespace '2htdp/image)])
>> (make-evaluator 'racket #:requires '(2htdp/image))))
>> (image? (ev '(rectangle 2 2 'solid 'blue)))
>
> This is what I meant by "complex (fiddling with namespaces)" but I see
> that happily it isn't complex and the sandbox happily does the
> fiddling for you.
>
> Robby
>