[racket] Sandbox, in a module, with a *shared* environment but *separate* I/O

From: Tony Garnock-Jones (tonyg at ccs.neu.edu)
Date: Thu Oct 27 15:45:31 EDT 2011

Hi all,

The example TCP-listening sandboxed REPLs given nearish the top of
http://docs.racket-lang.org/reference/Sandboxed_Evaluation.html differ
slightly: the one that only works from the toplevel shares a namespace
and evaluator between all the connections, but the one that works from a
module uses a fresh namespace and evaluator for each connection.

How can I set things up so that

 - a single "global environment" is shared between all connections, but
 - each connection gets its own input and output ports, connected
   to the socket?

I'd like to be able to connect in one terminal, say "(define x 123)",
then connect in another terminal and have "x" result in "123". I'd also
like "(display 'hello)" to print to the issuing terminal rather than
going only to one or the other.

Does this sound like a familiar problem? Have others solved this before?
I feel like I'm missing something about the distinction between
namespaces and evaluators...

Regards,
  Tony


Posted on the users mailing list.