Hi,

> >> The problem with recursive JS functions is that the end user most likely 
> >> ends up with a sluggish feeling browser.
> > 
> > How is recursion any less performant or more sluggish than repeatedly 
> > calling a function
> within a
> > loop (as in your code)?
> 
> What?  You've never seen the "Too many recursions" errors?
> Also, recursions stacks up quite a bit, and that leads to a sluggish 
> feeling browser.
> 

Yes, I have seen that error. For example:

(function() {arguments.callee();})();

It is my understanding "InternalError: too much recursion" is no different than 
a stack overflow
error. For instance:

// Create a long chain of functions and call
// the first in the chain
for (var i=0; i<9999; i++)
  eval("function a" + i + "(){ a" + (i+1) + "();}");
a0();

This also yields "InternalError: too much recursion" even though there is no 
recursion. A more
appropriate error description, IMHO, would be "Stack overflow error" or "No 
more stack space
available" because recursion is not necessary to overflow the stack.

So my question is, "Why would recursion be any less efficient (or more visible 
to the user as
sluggishness) than a function chain of the same depth?"

> Now I seriously need a cup of coffee and a proper breakfast!

Have some for me, too :)

-Eric
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners

Reply via email to