On Wed, Dec 10, 2008 at 16:22, Attila Szegedi <[EMAIL PROTECTED]> wrote:
> 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().
The difference is that if i compile it as a function it has suddenly state
inside it
If i do that as a script it doesnt have the state.
I want the function to be the same thing. No state all the state it gets
should be taken from the arguments that is given in the call(xxxx) method
(just like script does that)
also all our code are standalone functions like
function test()
{
// code
}
if i compile that as a script and say exec() then nothing happens because it
doesnt exec the function but just the scripts (which doesnt do anything)
besides that suddenly having arguments also is not possible for us because
many of our customers use "arguments" we cant just change that. So using a
Script instead of a Function is just not possible
I am currently investigating why it is that function object cant just be as
a script, why we really need to have suddenly a parent and prototype scope
which a Script (which also can have the same function it it) doesnt seem to
need
johan
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino