Thanks!
Looks like the problem is in the use of the toString function in your
original example:
>> function f() {
>> java.lang.System.out.println(toString(arguments));
>> }
>> f (1, 2, 3);
In that code fragment, toString() is being called as a standalone
function, not as a method on an object.
For operating on arguments, I generally make local references to the
Array.prototype methods, then call them on the arguments object.
For example:
var slice = Array.prototype.slice;
function foo( /* ... */ ) {
// make a copy of arguments, except that it's a true Array instance
var args = slice.call( arguments, 0 );
args instanceof Array; // true
print( args + '' ); // cast args as a string and print
}
Hope this helps!
-- Jim
On Fri, Apr 16, 2010 at 12:19 AM, Ravi Tanuku <[email protected]> wrote:
> This printed 1,2,3
>
> Regards,
> Ravi Tanuku
>
>
> -----Original Message-----
> From: Jim R. Wilson [mailto:[email protected]]
> Sent: Wednesday, April 14, 2010 8:28 PM
> To: Ravi Tanuku
> Cc: arvind; [email protected]
> Subject: Re: default argument object issue with Rhino1.7R2
>
> Hi Ravi,
>
> Could you run the following? I'm curious to see if it works, thanks!
>
> function f() {
> java.lang.System.out.println(
> Array.prototype.slice.call(arguments, 0).toString()
> );
> }
> f (1, 2, 3);
>
> -- Jim
>
>
> On Wed, Apr 14, 2010 at 1:03 AM, Ravi Tanuku <[email protected]> wrote:
>> Hi Jim,
>>
>> Thank you very much for the prompt reply.
>>
>> Here print() function is defined. To avoid this dependency, I modified the
>> function as follows.
>>
>> function f() {
>> java.lang.System.out.println(toString(arguments));
>> }
>> f (1, 2, 3);
>>
>> When I execute above script using rhino 1.6R5 API, it prints [1,2,3]
>> With 1.7R2 API, it prints {}.
>>
>> Can you please explain if there are any changes made to arguments object or
>> toString() method in 1.7R2?
>>
>>
>> Thanks,
>> Ravi Tanuku
>>
>> -----Original Message-----
>> From: Jim R. Wilson [mailto:[email protected]]
>> Sent: Tuesday, April 13, 2010 9:29 PM
>> To: arvind
>> Cc: [email protected]; Ravi Tanuku
>> Subject: Re: default argument object issue with Rhino1.7R2
>>
>> I recommend trying a simpler test: print("hi");
>>
>> If that doesn't work, maybe the print function isn't defined?
>>
>> java.lang.System.out.println( typeof print );
>>
>> Hope this helps!
>>
>> -- Jim R. Wilson (jimbojw)
>>
>> On Tue, Apr 13, 2010 at 6:38 AM, arvind <[email protected]> wrote:
>>> Hi ,
>>>
>>> function f() {
>>> print(arguments);
>>> }
>>> f (1, 2, 3);
>>>
>>> I am executing above program with different version of rhino library.
>>> then i found.
>>> it is not printing any thing else with Rhino 1.7R2 but it is printing
>>> correct value with Rhino 1.6R5 library.
>>> _______________________________________________
>>> dev-tech-js-engine-rhino mailing list
>>> [email protected]
>>> https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>>>
>>
>> This message and the information contained herein is proprietary and
>> confidential and subject to the Amdocs policy statement,
>> you may review at http://www.amdocs.com/email_disclaimer.asp
>>
>>
>
>
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino