From: Toby A. <tob...@pe...> - 2004-05-12 21:08:43
|
On Tue, May 11, 2004 at 11:35:51PM -0400, Timothy John Hickey wrote: > On May 10, 2004, at 6:35 PM, Toby Allsopp wrote: > > In this example, the variable called 'x is looked up in three > > different, nested evaluators. As each .eval finishes, the current > > evaluator must be restored to what it was when the .eval was called. > > So the stacks are needed because the implementation relies on > threadlocal variables and you need to reset the values of the > threadlocal variables when the evaluator is complete? Yes, that sums it up exactly. The implementation needs thread-local variables because the existing code relies on calls to static jsint.Scheme methods and I didn't see a clear direction for changing that. > > > Perhaps there are static methods in Scheme.java and other classes > > > that should simply be removed. For example, Scheme.runJscheme() > > > should no longer be static, so the currentEvaluator() call in that > > > method wouldn't be necessary. runJscheme() would have to be moved > > > to Evaluator, i guess. I think getting rid of the Scheme class > > > might be the way to go. > > I haven't looked at Toby's code yet, but I wonder if we can get by > without threadlocal variables? Perhaps a major revision (of > Scheme.java, Primitives.java, ...) would eliminate the need for this > complication (and the stacks of interpreters....) I actually think that a stack of thread-local variables will turn out to be the best solution, but I'm a big fan of Common Lisp-style special variables. The alternative is to pass a reference to the appropriate Evaluator instance through every method call, which seems a bit inelegant. Something like AspectJ might help here, although I don't imagine that fits in with other goals of the project. Toby. |