From murdoch.duncan at gmail.com  Wed Mar  7 16:37:58 2012
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Wed, 07 Mar 2012 10:37:58 -0500
Subject: [Rd] .Internal(inspect(x)) gives overly verbose output for
 reference classes
In-Reply-To: <CAPp_+=dunqwtXPChpx+7+s_PNG2CH=D5fVsaoXWwN-sECkLk8Q@mail.gmail.com>
References: <CAPp_+=dunqwtXPChpx+7+s_PNG2CH=D5fVsaoXWwN-sECkLk8Q@mail.gmail.com>
Message-ID: <4F5780D6.8020409@gmail.com>

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



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