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
Recursion problems and crashes
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Dear gmccarthy,
I'd say this is a Rev bug. I tried a slightly different script:
The last line in file testFile.txt is "3042 3042 13". I am very surprised that ths script can run only 6958 times. The file created by the script clearly shows that pNum changes from 10000 to 3042 and that there is no unexpected behaviour except for the crash (I added the wait line to give Rev time to close the file and do any housekeeping if necessary).
Setting the recursionLimit to a specific number doesn't help in any way, because nobody can translate this number to the number of times a recursive handler is allowed to run. I even doubt that the RunRev developers team can make this translation. If they can, I'd love to see the recursionLimit changed to something interpretable.
Best,
Mark
I'd say this is a Rev bug. I tried a slightly different script:
Code: Select all
constant kFile = "~/desktop/testfile.txt"
local lPrevTime
on mouseUp
delete file kFile
put 0 into lPrevTime
TestRecursion
end mouseUp
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
put the millisecs into myTime
put pNum & tab & (myTime-lPrevTime) & cr into myDif
put myDif
put myTime into lPrevTime
put kFile into myFile
open file myFile for append
put the result into rslt
if rslt is not empty then
beep
put rslt
exit fGetByRecursion
end if
write pNum & tab & myDif to file myFile
close file myFile
wait 0 millisecs with messages
if pNum = 1 then return pNum
else return pNum + fGetByRecursion(pNum -1)
end fGetByRecursion
Setting the recursionLimit to a specific number doesn't help in any way, because nobody can translate this number to the number of times a recursive handler is allowed to run. I even doubt that the RunRev developers team can make this translation. If they can, I'd love to see the recursionLimit changed to something interpretable.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode