Group Abstract Group Abstract

Message Boards Message Boards

2
|
8.5K Views
|
5 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Has the behavior of $RecursionLimit changed?

The tutorial Controlling Infinite Evaluation says:

When the Wolfram Language stops without finishing evaluation, it returns a held result. You can continue the evaluation by explicitly calling ReleaseHold.

It includes this minimal example:

In[1]:= x = x + 1

... $RecursionLimit: Recursion depth of 256 exceeded.

Out[2]= 255 + Hold[1 + x]

It appears this is no longer the behavior in version 11.3. Instead of evaluating to a partial result when $RecursionLimit is reached, the original expression wrapped in Hold is returned. Actually, to be more precise, when I evaluate x=x+1 on a fresh kernel I get Hold[x+1], but if I set $RecursionLimit to any valid number I get Hold[x=x+1].

In contrast, the behavior of $IterationLimit is as documented.

The Mathematica StackExchange discussion for reference: https://mathematica.stackexchange.com/questions/184259/unwanted-hold-from-recursive-function/

POSTED BY: Robert Jacobson
5 Replies

This is correct: the change was effectively intentional.

In slightly more detail, changes were made in handling of RecursionLimit overflows in order to improve the ability of the Mathematica kernel to return to a reasonable place rather than get lost in further recursion (as was happening in multiple-recursion situations). The change in form of the eventual result was a not necessarily intended byproduct.

Whether one views that new form in and of itself as better or worse, it was needed in order to achieve the bigger goal of repairing a severe problem with multiple recursion.

POSTED BY: Daniel Lichtblau
Posted 7 years ago

I think this is a case where the functionality intentionally changed, and the documentation wasn't entirely updated to properly reflect the changes.

I've reported this, and if it turns out my guess was incorrect I'll let you know.

POSTED BY: Kyle Martin
POSTED BY: Robert Jacobson

@RobertJacobson, I saw the questions but I don't have answers. There were a few changes made to address issues with deep recursion over the past nine or so years. The example x=x+1 has been through a few changes going back to 2009.

You are correct that deep iteration is unchanged (so far as I am aware).

POSTED BY: Daniel Lichtblau
POSTED BY: Robert Jacobson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard