[racket] Fresh sandboxes in Scribble documentation (was: Typed macros in untyped code)

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Nov 19 15:47:23 EST 2010

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)])
     (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

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.