Recursion

Yennie at aol.com Yennie at aol.com
Thu Aug 29 15:50:02 EDT 2002


> on theHandler
>     # do things
>     send theHandler to me in 1 millisecond
> end theHandler
> 
> Would this trigger a Metacard recursion count?
> 
It shouldn't. What happens is this:

1. theHandler is triggered.
2. A message is queued to trigger theHandler again.
3. theHandler finishes executing.
4. theHandler is triggered by the pending message.

As you can see, the first copy of the handler completes and exits in step 3. 
Thus, you only have one copy of the handler in memory at once.

On the other hand, this:

on theHandler
    # do things
    theHandler
end theHandler

Produces this result:

1. theHandler is triggered.
2. theHandler calls a second copy of itself.
3. The second copy calls a third.
4. The third copy calls a fourth.
...

After 4 steps there are 4 handlers in memory, and you are recursing. The 
first copy can't release until the second does, the second is waiting for the 
third, the third is waiting on the fourth, etc. Until all of those handlers 
start terminating without recursing any further, you'll just keep on eating 
memory- and Metacard will bail you out with an error.

HTH,
Brian



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.runrev.com/pipermail/metacard/attachments/20020829/b36bef1d/attachment.htm


More information about the metacard mailing list