[Project_owners] clearing variables

Konstantin Svist fry.kun at gmail.com
Mon Feb 6 19:23:05 EST 2006


Well, what's happening is you have some object which has a certain
number of levels, as in o.a.b.c.d.e.f.g.h... and if you're getting
that error, the JS interpreter must've been coded to check the size of
the stack and raise an error if it gets too high (this usually happens
in infinite loops)

How about turning it into a for loop instead of recursion?
It'll be annoying to code and read but it'll do the job without errors :)

maybe something like
for i in o
 if a[i] has children,
    append a[i] to o
 delete o[i]

this way, any structure deeper than 2nd level is brought down to 1st
level and the iteration continues on it until everything is deleted

On 2/6/06, Eric H. Jung <grimholtz at yahoo.com> wrote:
> With your comments in mind, I've written this function:
>
> var PwdMkr_MPW = {
>
>   // Recursively delete sensitive data
>   wipe : function(o) {
>     if (o) {
>       for (var i in o)
>         this.wipe(o[i]);
>       delete o;
>     }
>   },
>   ...
> };
>
> Often when I call this function (not always) I get: "Error: too much
> recursion". I realize this might be a Computer Science 101 question,
> but do you see anything wrong with my function?
>
> Thank you,
> Eric
>
>
> --- Konstantin Svist <fry.kun at gmail.com> wrote:
>
> > You know, I also thought it should cause an exception, but I tried it
> > in my browser (Fx 1.5.0.1) and it gives me false.
> > I guess it varies with implementation or depends on garbage
> > collection
> > or something like that.
> > the reason i didn't write '"foo" in this' was because I was trying to
> > generate an exception in the first place
> > I'm pretty sure I've seen it throw one a long time ago.. maybe it was
> > in IE..
> >
> >
> > On 2/6/06, Neil <neil at parkwaycc.co.uk> wrote:
> > > Eric H. Jung wrote:
> > >
> > > >By the way, 'foo in this' after 'delete foo' yields
> > 'ReferenceError: foo is not defined', not false.
> > > >
> > > I think he meant '"foo" in this'.
> > > _______________________________________________
> > > Project_owners mailing list
> > > Project_owners at mozdev.org
> > > http://mozdev.org/mailman/listinfo/project_owners
> > >
> > _______________________________________________
> > Project_owners mailing list
> > Project_owners at mozdev.org
> > http://mozdev.org/mailman/listinfo/project_owners
> >
>
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>


More information about the Project_owners mailing list