From: Andrew M. <and...@wi...> - 2004-05-07 07:49:55
|
Toby Allsopp <tob...@pe...> writes: > After some delay, here is the promised patch that allows one JVM to host > multiple JScheme instances that are isolated (or not if you want) from > each other. I can provide the entire changed files on request. This is great! Thank you. I hope these changes can be incorporated into the main branch. > > Note that there are two new files: src/jsint/Evaluator.java and > src/jscheme/SchemeEvaluator.java and one removed file: > src/jsint/SI.java. > > The two main changes are: > > 1) jscheme.JS now has to be instantiated rather than just having static > methods. > > 2) jsint.Scheme has been gutted and now delegates to a thread-local > instance of the new class jsint.Evaluator, which contains almost all of > the code from jsint.Scheme in non-static form. > > The way it works is that each JS instance has an instance of Evaluator, > which holds the global variables essentially. Whenever you invoke a > method on JS, it tells jsint.Scheme to use its Evaluator as the > thread-local Evaluator and any jsint code that calls static methods on > jsint.Scheme gets redirected to that Evaluator. > > For most users of JScheme the changes boil down to: > > JS js = new JS(); > js.eval("(define (f x) (* x x))"); > > rather than: > > JS.eval("(define (f x) (* x x))"); > > Any feedback on these changes is welcome. If you choose to incorporate > them then my job becomes much easier :-) > > Toby. > > -- andy |