On 2008.12.10., at 16:14, Johan Compagner wrote:
ok scripts seems to be stateless yes
Problem is we cant use that, we really have functions that we want to
execute like this:
Object o = f.call(cx, scope, thisObject, args);
and then that function is called with the args we want to give it..
this is not possible with a Script because a script only has:
compileString.exec(cx, scope);
as you can see almost the same thing.. except that a function has a
bit more
state pushed to it
So why is there a difference in a function or a script?
Well, the only real difference I can see is that a script can't have a
positional list of named arguments, and also that for scripts this ==
scope. You'd put those instead as named properties of the scope and
they'd then appear as global variables (as that scope then acts as the
global scope for that execution). But the script can also return a
value just fine -- the expression value of the last statement is
returned from Script.exec().
Attila.
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino