Hi, I was just experimenting with some older code I have in the new 4.6
release and I have discovered that while the 4.4 code seemed to handle
tail recursion moderately well, 4.6 does not see any difference. As a
result, the recursion limit of 250 is slapped on.
E.g. in 4.6
gnuplot> tr(x, s) = (x < 1 ? s : tr(x-1, s+x))
gnuplot> print tr(250,0)
31375
gnuplot> print tr(251,0)
recursion depth limit exceeded
By contrast, the non tail-recursive function
t(x) = (x < 1 ? 0 : x+t(x-1))
only has a stack overflow at x=250.
in 4.4, print tr(20000,0) worked fine, while t(99) gave a stack
overflow.
gnuplot> show all
G N U P L O T
Version 4.6 patchlevel 0 last modified 2012-03-04
Build System: Linux i686
Question: is this an intended change?
--
Leo Butler l_b...@us...
SDF Public Access UNIX System - http://sdf.lonestar.org
|