[Rd] .Internal(inspect(x)) gives overly verbose output for reference classes

Duncan Murdoch murdoch.duncan at gmail.com
Wed Mar 7 16:37:58 CET 2012

On 12-03-07 9:52 AM, Richard Cotton wrote:
> Even for an extremely simple instance of a reference class
> x<- setRefClass("x")
> y<- x$new()
> calling the internal inspect function
> .Internal(inspect(y))
> produces enough output that it takes several minutes to print to the
> console.  (Actually I gave up and terminated the command after ~10
> mins.  It isn't clear whether the output would eventually complete.)
> Are reference classes really so complicated inside, or is this a bug?
> ______________________________________________

If you look at the output, you'll see it's looping.  When I hit Esc, I 
saw that .self is an S4SXP with an attribute .xData which is an 
environment containing the same .self, ad infinitum.

So I'd say it's a bug in inspect().  It can handle the case of an 
environment holding itself, but I think it was written before S4SXPs 
contained themselves, and it looks like it's not checking for that.

I'll take a look if someone else doesn't get there first...

Duncan Murdoch

More information about the R-devel mailing list