[Courses] [Ruby] Lesson 2: Iterators
Laurel Fan
laurel.fan at gmail.com
Sat Dec 10 04:13:17 EST 2005
On 12/9/05, Anne G <anne at wjh.harvard.edu> wrote:
> This worked very well, getdata calls getinfo1 which calls
> getinfo2 which calls getdata ad infinitum. The problem I
> encounted is that ad infinitum is not supported by my
> implementation of Ruby, I got an error message, too many
> levels (each repeat call on getdata is a level).
>
> Of course I can find ways to write the code more efficiently
> to avoid the limit, but by calling a method for each line of
> code, I encountered a limit, and the fact that the limit
> exists is what bothers me. That means I have to make sure
> the whole program is done is so many calls. This is not a
> stable timeless implementation. It could not run on live
> data that kept coming and coming.
Now I think I understand a bit more of what the problem is.
Recursion (methods calling themselves) might not be the best solution
for data that keeps coming continuously. Each recursive method call
causes a little bit of overhead (it needs to keep track of every
method currently running), and this can add up over time.
It's also possible that there's a bug in the code causing an infinite
recursion loop.
Without seeing all of your code, it's hard to tell what exactly the
problem is, or whether there would be a better way to implement it
without recursion. Would you be willing to post the whole thing to
the list?
--
Laurel Fan
http://dreadnought.gorgorg.org
More information about the Courses
mailing list