Subj : Rhino - looking for ways to reset a scope.txt To : netscape.public.mozilla.jseng From : ariel_ml@netvision.net.il (Ariel Malka) Date : Wed Aug 27 2003 04:50 pm Taking in count that: - Context.Enter() and Context.initStandardObjects() are producing (harmless but annoying) exceptions with the MS JVM. - Context.initStandardObjects() seems to be an "expensive" method. I would like to minimize the invocations of these 2 methods. If i only wanted to produce a javascript interpreter which function in a kind of "interactive-mode" (scope information is conserved between successive runs), i guess i would just put these 2 methods at the beginning of my applet and that' all. But i want to produce an interpreter which can also work in "execution-mode" (scope information should be cleared, before each run). In this case, is there a way (other than initStandardObjects) to reset a scope? Actually, the answer may lie in the following question: Let's say i'm using a custom ScriptableObject named Shell which gives access to a "print" function. For initialization, I would use: cx = Context.enter(); Shell global = new Shell(); cx.initStandardObjects(global); String[] names = { "print" }; try { global.defineFunctionProperties(names, Shell.class, ScriptableObject.DONTENUM); } catch (PropertyException e) {} The question is: if i want to reset the scope at each new execution, should i repeat the same initialization code? (seems a bit overkill). Note: by reseting the scope, I mean essentially clearing all the user-defined variables, functions, etc. that have been created during a previous execution. Any clues? Thanks! .