Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Array mutating after scope change?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
kuno  
View profile   Translate to Translated (View Original)
 More options Jun 26 2012, 1:35 pm
From: kuno <neok...@gmail.com>
Date: Tue, 26 Jun 2012 10:35:26 -0700 (PDT)
Local: Tues, Jun 26 2012 1:35 pm
Subject: Re: Array mutating after scope change?

On Tuesday, June 26, 2012 8:34:46 PM UTC+8, Bradley Meck wrote:

> It would be helpful to see some more code, for example, is `query` ever
> exposed in the outside scope? Where is it referenced for usage rather than
> population?

> On Tuesday, June 26, 2012 4:43:26 AM UTC-5, kuno wrote:

>> This error occurs on node 0.6.19, not sure be fixed on 0.8 or not.

>> suppose I have a nest function like this:
>> <=======================================
>> function outer() {
>> var query = {};
>> query.startkey = [];
>> query.endkey = [];

>> query.startkey.push('report');
>> query.startkey.push({});

>> var keysCallback =  function(result) {
>>      query.startkey.push(result.key1);
>>      query.startkey.push(result.key2);
>>       ......
>> }

>> getResultFunction(args, keysCallback);
>> }
>> ======================================>
>> most time, it works well, but in some very very rare chance, I got the
>> error like this:

>> <=======================================

>> Object ["report",{}] has no method 'push'

>> ========================================>
>> if we inspect it, it'll tell that query.startkeys is an object with the
>> array literal notation '["report",{}]', but not a real array.

>> Since it occurs inside the inner keysCallback, but query.startkey was
>> defined explicitly in the outer function, and works well.
>> This make methink maybe there are some runtime errors, during the runtime
>> lookup the query.startkeys from the scope of keysCallback to the outer
>> function.

>> But I am not a expert on v8, so this is just a suspection. I'd like to
>> hear your opinion about this.

>> --thanks

>> kuno

I agree, but since this is a private project of our company, I am afraid
I'm not allowed to show the real code.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.