recursion limits

Phil Davis davis.phil at comcast.net
Wed Aug 3 19:47:32 EDT 2005


Hi Chris,

I've had apps quit due to recursion, but it's been a while ago. Unless 
there's a compelling reason to use true (nested) recursion, I always 
avoid it. You can accomplish the same effect by scheduling the next 
iteration of a handler from within itself in 0 seconds. It just means 
you can't have nested iterations of a handler, so you have to design 
your logic to accommodate that fact.


So instead of this:
on runMe
   -- do stuff
   runMe
end runMe


You have this:
on runMe
   -- do stuff
   send "runMe" to me in zero seconds
end runMe


Side benefit: Because your processing isn't nested but effectively has 
idle time between handler runs, you can interrupt it with UI activity. 
That can't be said of nested iterative execution.

HTH -
Phil Davis



Chris Sheffield wrote:
> I know recursion has been discussed in the past, and I'm wondering if  
> anyone has ever run into any limits (i.e. memory problems) with  
> recursion in Rev.  I am working on a little backup utility for my own  
> use, and I'm wondering what would happen if I decided to back up my  
> entire hard drive?  Would Rev choke on that?  I realize it could  
> potentially take hours.  Would I start getting out of memory errors?   
> The utility uses a directory walking function to create a list of all  
> sub folders and files to be backed up.
> 
> Anyone have some detailed results with this type of thing?
> 
> Thanks,
> Chris
> 
> 
> ------------------------------------------
> Chris Sheffield
> Read Naturally
> The Fluency Company
> http://www.readnaturally.com
> ------------------------------------------



More information about the use-livecode mailing list