Subj : Re: 'Replacing' loaded functions and host objects in a shared scope To : Eric Merritt From : Igor Bukanov Date : Fri Aug 22 2003 05:25 pm Eric Merritt wrote: > Igor; > > Thanks, at least my fears are validated. I will > continue with the current approach which is to discard > the scope, recreate it and the reload all of the host > objects, library functions, and an script scopes that > use it as a prototype. > > That brings up another issue, can I keep the script > (sub)scopes and just do another 'setPrototype' with > the new lib scope without any undue concerns? Each function contains as its prototype a reference to Function.prototype thus the simple approach of changing scope would not work as some of objects from the previous standard library would exist and may cause bad interaction with your setup. If you want to save on script parsing/byte code generation which is the most time consuming part of script evaluation unless you have loops outside functions or call functions with loops or recursion, then use Context.compileReader/compileString to get a Script object that is scope independent and store it. Then after reloading your library create a new script scope, set its prototype according to your needs and call Script.eval Regards, Igor .