[racket] Limiting net-repl provided functions

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Jun 28 02:45:15 EDT 2011

About a minute ago, Jukka Tuominen wrote:
> 
> > The sandbox is working in an isolated world (by design, of
> > course), so you need to do the (require "sb-functions.rkt") inside
> > the sandbox.  For example, just use (sb-eval '(require ...)).
> 
> Wouldn't that mean that the sb-evaluator has to be first initiated
> to understand 'require' plus many other primitives, not just the
> intented f1, f2, f3?

Yes.


> Is this even possible?

Yes.  You can get that with

  (make-evaluator 'racket/base)

If you want a limited language, then you can make up a language with
`require' and the limited set of bindings you want in.  If you also
don't want `require' in the language, you can make the language itself
provide the functions that you want to make public, but not `require'
itself.  Yet another option is to use `call-in-sandbox-context' with
`namespace-require'.

(All of this is much more complicated then what Matthias originally
hinted at: if you know the set of functions that you want to expose,
then you can just dispatch on the input symbols and call the
corresponding function.)

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


Posted on the users mailing list.