[R] contextstack overflow

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Feb 20 21:07:35 CET 2007


On Tue, 20 Feb 2007, Steven Finch wrote:

> Hello!
>
> I written several implementations in R of Rémy's algorithm for
> generating random ordered strictly binary trees on 2n+1 vertices.
>
> One implementation involves manufacturing character strings like:
>
> "X <- list(0,list(0,0))"
>
> for the case n=2.  If I perform the following two steps:
>
> cmd <- "X <- list(0,list(0,0))"
> eval(parse(text=cmd))
>
> then X becomes a true nested list in R.  This works fine for n=2,
> but often for n=200, an error message:
>
> Error in parse(text = cmd) : contextstack overflow
>
> appears and execution stops.  Clearly there exists an upper bound
> on the allowable depth of nestings in R!  Can this upper bound be
> easily increased?

It is hardcoded (as 50) in 6 places in gram.c, so fairly easily changed.

> Other implementations avoid this problem, so this issue is not
> crucial to me.  I do wish, however, to understand the limits of
> this particular approach.  Thank you!
>
> Steve Finch
> http://algo.inria.fr/bsolve/
>
> P.S.  If anyone else has written R code for generating random
> trees (on a fixed number of vertices), I would enjoy seeing this!
>
> _________________________________________________________________
> Don’t miss your chance to WIN 10 hours of private jet travel from Microsoft® 
> Office Live http://clk.atdmt.com/MRT/go/mcrssaub0540002499mrt/direct/01/
>
>

-- 
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-help mailing list