From ripley at stats.ox.ac.uk  Mon Jan 24 17:03:55 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon Jan 24 17:04:09 2005
Subject: [Rd] Very Long Expressions
In-Reply-To: <67DCA285A2D7754280D3B8E88EB5480206741E31@MSGBOSCLB2WIN.DMN1.FMR.COM>
References: <67DCA285A2D7754280D3B8E88EB5480206741E31@MSGBOSCLB2WIN.DMN1.FMR.COM>
Message-ID: <Pine.LNX.4.61.0501241554410.3211@gannet.stats>

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@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


[Rd] Very Long Expressions
Prof Brian Ripley