Tail recursion, and limits

Geoff Canyon gcanyon at gmail.com
Fri Apr 26 12:22:40 EDT 2013


So I was curious whether LC optimizes tail calls. It appears not. But even
stranger, this code busts the recursion limits. It should only call itself
900 times, right? And am I correct that if LC optimized tail calls, then
this would work regardless of the recursionLimit.


on mouseUp
   answer the recursionlimit -- this answers 400,000
   put incrementer(1,900)
end mouseUp

function incrementer x,steps
   if steps < 1 then return x else return incrementer(x+1,steps-1)
end incrementer



More information about the use-livecode mailing list