Print

Print


<<<
"that is going to silently return the wrong answer if it gets called 
recursively."  But what can the silent wrong answer be in this case since the 
context is finalization?  That is, can it be anything besides a memory leak?
>>>

The silent wrong answer could be anything, since there will be a single variable 
shared between all the recursive instances, instead of one per instance.

It depends very much on exactly how the computation proceeds: in the case of 
simple tail recursion, the variable is not going to be used by the caller any 
more so it probably won't matter.  But in the more usual cases, recursing will 
overwrite the variable that still contains values that will be used.  Whether 
that leads to memory leakage, the "wrong answer", or some incredibly mysterious 
crash an hour later depends entirely on what the variable contains and how it is 
being used.

Cheers,
-- 
................................Malcolm Cohen, Nihon NAG, Tokyo.