(load "file.scm") in a New Environment in Scheme -


MIT scheme's (load ...) process as a parameter Is that I can "clone" the current environment and pass it there so that I can isolate the environment of the file itself?

(I have seen but I did not find anything ...

How about something?

  (define clone-env env) ((binding (environment binding env)) (make-top-level-environment (map car binding) (Map Cadre Binding))) 1) = & gt; (Define FU1; value: foo 1] => (The-environment) (Clon-env (the-environment); Value: #f   < P> Edit to edit:  

I am not exactly what you are trying to do, but I have done here to check the above. I have the file foo. Scm containing:

  (set! Foo 2) is created (defaults to Falcon (+ Fu Foo)) baz   

then ,

  1] => (define FU1; value: foo 1] => (load "foo.scm" (clone - env ​​(the-environment)); "foo.scm" is loading ... value: 4 1] => Foo; value: 1 1] => Buzz; Unbound Variable: To continue, call RESTART with an option number:; (RESTART 3) = & gt; Specify a value to use instead of the falcon; (RESTART 2) = & gt; A given value Define the buzz in; (RESTART 1) => return to the eval-print level. 2 error>    

Comments