Recursion problems and crashes
Posted: Mon Feb 23, 2009 1:11 pm
Can someone tell me in what ways RunRev is supposed to deal with recursion?
The user guide on p41 states that the Maximum level of recursion is Unlimited.
The dictionary includes the info:
By default, the recursionLimit property is set to 1000000.
The relationship between the recursionLimit and the number of levels of nesting permitted for a recursive call depends on a number of factors, including the processor type and the number of parameters passed during each function call. This means that the same recursionLimit value may allow a different maximum level of nesting, depending on the platform.
The default actually appears to be 400000 if "put the recursionLimit" is entered on starting Rev.
[The background was that I had a recursion problem in a stack that kept crashing on a certain action till I found the problem code and fixed it. However I endured a number of forced quits and "hold in the start button" shutdowns and restarts on OS X 10.3.9]
The following test code --set up to test recursion-- results in crashes: full system crashes on OS X and crashes on windows.
The try structure didn't seem to help.
Should Run Rev handle this limited recursion or run away recursion without crashing?
Should the try structure deal with this?
TestRecursion
command TestRecursion
set the recursionlimit to "400000000000"
put 10000 into pNum
try
put fGetByRecursion(pNum) into cd fld "Total"
catch tError
put tError
end try
end TestRecursion
function fGetByRecursion pNum
if pNum = 1 then return pNum
else return pNum + fGetByRecursion(pNum -1)
end fGetByRecursion
The user guide on p41 states that the Maximum level of recursion is Unlimited.
The dictionary includes the info:
By default, the recursionLimit property is set to 1000000.
The relationship between the recursionLimit and the number of levels of nesting permitted for a recursive call depends on a number of factors, including the processor type and the number of parameters passed during each function call. This means that the same recursionLimit value may allow a different maximum level of nesting, depending on the platform.
The default actually appears to be 400000 if "put the recursionLimit" is entered on starting Rev.
[The background was that I had a recursion problem in a stack that kept crashing on a certain action till I found the problem code and fixed it. However I endured a number of forced quits and "hold in the start button" shutdowns and restarts on OS X 10.3.9]
The following test code --set up to test recursion-- results in crashes: full system crashes on OS X and crashes on windows.
The try structure didn't seem to help.
Should Run Rev handle this limited recursion or run away recursion without crashing?
Should the try structure deal with this?
TestRecursion
command TestRecursion
set the recursionlimit to "400000000000"
put 10000 into pNum
try
put fGetByRecursion(pNum) into cd fld "Total"
catch tError
put tError
end try
end TestRecursion
function fGetByRecursion pNum
if pNum = 1 then return pNum
else return pNum + fGetByRecursion(pNum -1)
end fGetByRecursion