Re: [Rd] new.env does not recognize parents from subclassesof "environment"

From: John Chambers <jmc4_at_stanford.edu>
Date: Thu, 21 Oct 2010 10:26:20 -0700

  This is a problem related to the introduction of exact= into the [[ and [[<- functions. As Bill says, the current method misuses eval.parent() when that argument is added.

However, a simpler and more efficient solution is to migrate the checks for subclasses of "environment" used in other base code into the code for [[<- (and for $<-), at which point the methods for these functions are no longer needed.

A solution on these lines is being tested now and will find its way into r-devel and 2.12 patched.

One other point about the original posting:

Please don't use constructions like env@.xData. This depends on the current implementation and is not part of the user-level definition. Use as(env, "environment") or equivalent. (In this case, the assignment of the object's own environment was irrelevant to the error.)

John Chambers

On 10/21/10 9:21 AM, William Dunlap wrote:
> The traceback looks very similar to a problem
> in R 2.11.1 reported earlier this month by Troy Robertson.
> > From: r-devel-bounces_at_r-project.org
> > [mailto:r-devel-bounces_at_r-project.org] On Behalf Of Troy Robertson
> > Sent: Wednesday, October 06, 2010 6:13 PM
> > To: 'r-devel_at_R-project.org'
> > Subject: Re: [Rd] Recursion error after upgrade to
> > R_2.11.1[Sec=Unclassified]
> It was due to a miscount of how many frames to go
> up before evaluating an expression in
> getMethod("[[<-",".environment") because setMethod()
> introduced a local function in the new method.
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>> -----Original Message-----
>> From: r-devel-bounces_at_r-project.org
>> [mailto:r-devel-bounces_at_r-project.org] On Behalf Of Vitally S.
>> Sent: Thursday, October 21, 2010 9:00 AM
>> To: John Chambers
>> Cc: r-devel_at_r-project.org
>> Subject: Re: [Rd] new.env does not recognize parents from
>> subclassesof "environment"
>>
>>
>>
>> Here is an infinite recursion error which occurs only with S4
>> subclasses assignment.
>>
>> setClass("myenv", contains = "environment")
>> #[1] "myenv"
>> env<- new("myenv")
>> env[[".me"]]<- ∑
>> #Error: evaluation nested too deeply: infinite recursion /
>> options(expressions=)?
>>
>>
>> With basic types it works as expected:
>>
>> env1<- new.env()
>> env1[[".me"]]<- env1
>>
>> May be this is related to active bindings that you mentioned,
>> but I am still
>> reporting it here.
>>
>> Vitally.
>>
>>
>>> Thanks for the report. Should now be fixed in r-devel and
>> 2.12 patched (rev 53383).
>>> Please do report any cases where a subclass of environment
>> doesn't work. There are some known cases in locking and
>>> active binding, that will be fixed in due course.
>>>
>>> The workaround for any such problem is usually as.environment().
>>>
>>> On 10/20/10 3:17 AM, Vitaly S. wrote:
>>>> Dear Developers,
>>>>
>>>> A lot has been changed in the R12.0 with respect to
>> behavior of "environment"
>>>> subclasses. Many thanks for that.
>>>>
>>>> One small irregularity, though; new.env does not allow the
>> parent to be from S4
>>>> subclass.
>>>>
>>>>
>>>>> setClass("myenv", contains="environment")
>>>> [1] "myenv"
>>>>> new.env(parent=new("myenv"))
>>>> Error in new.env(parent = new("myenv")) : 'enclos' must be
>> an environment
>>>> I wonder if this is a "planed" behavior.
>>>>
>>>> The use of .xData slot obviously works:
>>>>> new.env(parent=new("myenv")@.xData)
>>>> <environment: 063bb9e8>
>>>> Thanks,
>>>> Vitaly.
>>>>
>>>> ______________________________________________
>>>> R-devel_at_r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel>
>> ______________________________________________
>> R-devel_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 21 Oct 2010 - 17:40:25 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 22 Oct 2010 - 18:10:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive