-- from a message from steven parkes on the envjs list --
What will make this really killer is using evaluateString to
load scripts, rather than raw eval():
http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/Context...
You pass it the window object for the script and it will cause
the string to be evaluated in the correct scope. This is the stuff
that Glen was using scope manipulation to achieve.
I think it also has the advantage of passing filename/line
number info to the compiler, so the error messages are better. I do
that on the SpiderMonkey side in some places but I think we can do
more. There are places in env.js where we do a straight eval()
where I think we might want to do a platform call, to give it the
option to do some value added stuff like filenames. (I think
everybody hates that when you do XHR/eval instead of
document.write(
You can also do what I do in SpiderMonkey which is use separate
compile and execute steps which allows me to cache the compiler
output so I only have to compile a script once even if it gets
execute multiple times.