chickadee » sandbox » safe-environment-set!

safe-environment-set! ENVIRONMENT ID VALUEprocedure

Sets the value of the variable named ID in ENVIRONMENT to value, creating a new binding if no variable with this name exists (it doesn't check the parent environment). Use this procedure to add additional primitives to an evaluation context:

(define my-env
  (make-safe-environment parent: default-safe-environment) )

(safe-environment-set!
  my-env 'hello
  (lambda (arg) 
    (display "Hello, ")
    (display arg)
    (display "!\n") ) )

(safe-eval '(hello "you") environment: my-env)

; prints:

Hello, you!

This procedure doesn't care whether an environment is mutable (or extendable) or not.