[racket] Fresh sandboxes in Scribble documentation

From: Neil Toronto (neil.toronto at gmail.com)
Date: Fri Nov 19 16:18:32 EST 2010

Eli Barzilay wrote:
> After talking to Sam about it, he pointed out the further problems
> that you get into with TR's limitations wrt the repl.  A potentially
> simple solution for this would be a variant of the the interactions
> thing that will get some code then run it as a *module*, and show the
> results, instead of using the evaluator for the examples.  Something
> along the lines of:
>   (parameterize ([sandbox-output (current-output-port)])
>     (kill-evaluator
>      (make-module-evaluator "#lang racket\n(+ 1 2)\n")))
> so the examples are changing from repl-input/-output to
> definitions-window/interactions-results.  This is probably not hard to
> do, but it will still imply an expensive cost for TR which is
> much slower to start even with everything shared.
> Yet another option, one that will be much faster but more difficult to
> implement, is to slap all of the examples into one module, then have a
> custom evaluation handler so you can see which output is printed for
> each piece of input.  This will require some delaying for text
> rendering, and you'll have the no-redefinitions problem in a worse
> way.

These sound like nice ideas, and I'd love to try them, but I'm still 
trying the factory method. I have only a shadow of a mental model of 
sandboxed evaluation, so I can't make sense of this error:

(define make-bigfloat-eval
    '(typed/racket/base "../bigfloat.rkt")))


namespace-attach-module: a different module with the same name is 
already in the destination namespace, for name: 

This is from the latest sources on github.

I get the same error using `make-eval-factory', or leaving out 
`typed/racket/base', or replacing the module paths with '(ffi/unsafe) or 
apparently anything else. The only things that seem to work are 
(make-base-eval-factory '()) and (make-eval-factory '()).

I couldn't find a non-trivial example of using eval factories in the 
collects, but what I tried *looks* fine according to the docs.

(On the plus side, the second time I evaluate (make-bigfloat-eval), I 
get the error WAY faster. So... improvement!)

Neil T

Posted on the users mailing list.