Thank you for such a detailed and helpful response. Are you able to tell me when this change was introduced? (It must have been <= v11.1.0.0.)
As far as I can tell, $IterationLimit
is unaffected. Is this correct? E.g., this still works:
In[1]:= f[n_]:=f[n+1]
In[2]:= f[1]
$IterationLimit::itlim: Iteration limit of 4096 exceeded.
Out[2]= Hold[f[4096 + 1]]
In[3]:= ReleaseHold[%]
$IterationLimit::itlim: Iteration limit of 4096 exceeded.
Out[3]= Hold[f[8191 + 1]]
If $IterationLimit
is unaffected and $IterationLimit
and $RecursionLimit
now behave differently, then:
- It is now important for programmers to know when they will encounter one versus the other, which is not at all clear from the documentation even if it is updated to reflect the new behavior. The obvious answer for experts is, "tail-recursion," but experts are presumably already writing tail-recursive expressions. (*ahem*)
- The resulting expression obtained from hitting the
$RecursionLimit
during evaluation is no longer very meaningful. Applying ReleaseHold
only repeats the original computation that has failed already. Considering the change, I intend to put in a feature request that expressions that hit the $RecursionLimit
during evaluation return $failed
. This change would have the additional advantage of further distinguishing between $IterationLimit
and $RecursionLimit
.
I'm happy to send the documentation bug reports and the feature request through the correct channels, but I'm interested in the answers myself.