I think this is implementation specific, but in MIT Scheme you can clear REPL environment with
1 ]=> (ge (make-top-level-environment))
Function (ge [environment]) "Changes the current environment of the REP loop to [environment]." and the make-top-level-environment function "returns the newly selected make-top-level-environment ."
MIT Scheme has many environmental management features that you can view here.
I tested this on Mac OS X (10.6.7) using MIT Scheme 9.0.1 installed via a prebuilt binary from the GNU site, with the following REPL session:
1 ]=> (define foo 1) ;Value: foo 1 ]=> foo ;Value: 1 1 ]=> (ge (make-top-level-environment)) ;Value 13: #[environment 13] 1 ]=> foo ;Unbound variable: foo ;To continue, call RESTART with an option number: ; (RESTART 3) => Specify a value to use instead of foo. ; (RESTART 2) => Define foo to a given value. ; (RESTART 1) => Return to read-eval-print level 1. 2 error>
I think different implementations have different conventions, but I donβt think that something is very similar to Common Lisp. If you are not tied to the MIT Scheme, you should check out Racket and Dr Racket, which is a good IDE that can be more powerful than a simple REPL on the command line, and I think it has some kind of modular system. A racket is your own dialect of the Scheme, so depending on what you do, it may not be practical. (the default language module in Racket is not the same as the MIT scheme)
I struggled with all this recently (the last few months) when I went looking for a scheme that could run code from Lisp in Small Pieces that has a bunch of weird macros. Gambit was the best choice. If you do not have such a need, check out Racket.
source share