[Rd] Very Long Expressions

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jan 24 17:03:55 CET 2005

On Mon, 24 Jan 2005, McGehee, Robert wrote:

[Instructions to the R developers deleted.]

> Secondly, the ?options help (thanks for everyone who reminded me about
> this), says that expressions can have values between 25...100000.
> However, if the original example is set past 4995 on my computers, I
> receive a stack overflow.

More accurately, you caused a protection stack overflow.

>> eval(parse(text = paste(rep(1, 4996), collapse = "+")))
> Error: protect(): stack overflow
> I'm pointing this out not because I will ever approach anywhere near
> this level of nesting, but perhaps that options(expression=5000+) might
> not be meaningful anyway, (unless there are
> processor/compilation-specific ways of getting rid of this stack
> overflow). If so, one might considering lowering the range of valid
> expressions values in the help file.

It's the protect stack you are overflowing, and there are ways to increase 
that (look at the command-line flags) and other nested computations that 
do not protect repeatedly.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-devel mailing list