Scheme based Operating System
Collection of visible bindings
> (define foo 1) > foo 1 ; foo is in the environment > bar error - bar not bound ; bar not in the environment
> (define foo 10) ; undefined > foo 10 > (eval 'foo (interaction-environment)) 10 > (with-environment (interaction-environment) foo)) 10 > (with-environment (make-environment (empty-environment)) foo) error - foo undefined
> (define foo 10)
; undefined
> foo
10
> (eval 'foo (interaction-environment))
10
> (with-environment (interaction-environment)
foo))
10
> (with-environment (make-environment (empty-environment))
foo)
error - foo undefined
> (define foo 10)
; undefined
> foo
10
> (eval 'foo (interaction-environment))
10
> (with-environment (interaction-environment)
foo))
10
> (with-environment (make-environment (empty-environment))
foo)
error - foo undefined
> (define foo 10)
; undefined
> foo
10
> (eval 'foo (interaction-environment))
10
> (with-environment (interaction-environment)
foo))
10
> (with-environment (make-environment (empty-environment))
foo)
error - foo undefined
> (define foo 10)
; undefined
> foo
10
> (eval 'foo (interaction-environment))
10
> (with-environment (interaction-environment)
foo))
10
> (with-environment (make-environment (empty-environment))
foo)
error - foo undefined
> (define foo 10)
; undefined
> foo
10
> (eval 'foo (interaction-environment))
10
> (with-environment (interaction-environment)
foo))
10
> (with-environment (make-environment (empty-environment))
foo)
error - foo undefined
> (with-input-from-file "passwords" (lambda () (read))) all my passwords > (print-file "untrusted-file-from-internets.scm") _(define (run) _(with-input-from-file "passwords" (lambda () (read)))) > (with-environment/files (no-i/o-environment) '("untrusted-file-from-internets.scm") (run)) error - with-input-from-file not defined
> (with-input-from-file "passwords"
(lambda () (read)))
all my passwords
> (print-file "untrusted-file-from-internets.scm")
_(define (run)
_(with-input-from-file "passwords"
(lambda () (read))))
> (with-environment/files (no-i/o-environment)
'("untrusted-file-from-internets.scm")
(run))
error - with-input-from-file not defined
> (with-input-from-file "passwords"
(lambda () (read)))
all my passwords
> (print-file "untrusted-file-from-internets.scm")
_(define (run)
_(with-input-from-file "passwords"
(lambda () (read))))
> (with-environment/files (no-i/o-environment)
'("untrusted-file-from-internets.scm")
(run))
error - with-input-from-file not defined
> (with-input-from-file "passwords"
(lambda () (read)))
all my passwords
> (print-file "untrusted-file-from-internets.scm")
_(define (run)
_(with-input-from-file "passwords"
(lambda () (read))))
> (with-environment/files (no-i/o-environment)
'("untrusted-file-from-internets.scm")
(run))
error - with-input-from-file not defined
> (define (no-i/o-environment) (make-environment (empty-environment) (import (scheme base))))
Code can only import packages it's environment has a reference to
i.e. no-i/o-environment can't import (scheme files) to get file i/o
References (partial list):