Re: [Rd] Attributes of top level environments clobbered (was Re: [R] possible bug in function 'var' in R 2.7.2?)

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri, 03 Oct 2008 13:25:50 -0400

On Fri, Oct 3, 2008 at 12:46 PM, Luke Tierney <luke_at_stat.uiowa.edu> wrote:
> On Fri, 3 Oct 2008, Gabor Grothendieck wrote:
>
>> On Fri, Oct 3, 2008 at 11:43 AM, Luke Tierney <luke_at_stat.uiowa.edu> wrote:
>>>
>>> I will look into fixing it sometime if no one else feels like doing
>>> it. The environment aspect is not high priority; some other related
>>> issues are more so (locking and active bindings as I recall). But
>>> even thoughs may not make it to the top of my queue any time soon.
>>>
>>> The issue of placing attributes on environments has come up before,
>>> many times. It is routinely advised against. For better or worse,
>>> the way environments were exposed to the R level is not designed to
>>> support this properly. Fixing this so that attributes are supported
>>> reliably is non-trivial, and it is hard to justify the effort given
>>> that there are standard work-arounds (such as putting the environment
>>> in a list and attaching attributes to the list). An alternative way
>>> of removing the issues associated with attributes on environments, in
>>> line with the way NULL works, is to disable placing attributes on
>>> environments, at least from the R level. This option is looking
>>> increasingly attractive.
>>
>> These are not good options:
>>
>> - the workaround does not allow one to inherit methods. This
>> implies tediously rewriting or writing wrappers every inherited method
>> in any such subclass. Its really tantamount to eliminating OO for
>> environments which is not a reasonable solution for a language that
>> is supposed to be OO.
>
> It would mean sealing environments, making them final, pick your
> favorite OO terminology. Standard thing to do in many OO languages
> when it is wararanted.

I don't think this really addresses the problem. The S3 model is in principle capable of handling environments and almost does so fully now.

>
>> - eliminating attributes on environments is even worse since widely
>> used packages such as proto, ggplot2 and other packages would suffer.
>> Maintaining reasonable compatiblity should be a goal of the core
>> development. It would be better to document the current situation than
>> to make such a retrograde change.
>
> The authors of proto would finally need to bite the bullet and address
> this issue. This would make proto more reliable in the end.

The fact that environment attributes get clobbered at top level when defined in packages with lazy loading (but not outside packages nor in packages without lazy loading) is clearly a deficiency of R, not proto.

Furthermore, the suggstion that this deficiency in R somehow reflects any unreliably in proto is likewise not accurate. proto is extremely reliable, particularly in
comparison to R. In fact there are no known bugs in the development version of proto and large widely used packages use proto. (If you are aware of any bugs let me know.) The fact that it is so solid is quite understandable because
even if some of its code is necessarily complex the code is so short that its readily possible to accomplish this apprent bug-free status with reasonble effort. Furthermore, the proto home page documents the problems -- mostly problems with R itself, not proto.

I do appreciate the excellent R software; however, there are a few points like those addressed on the proto home page which do need to be addressed in R for it to be fully functional.

>
> luke
>
>> - if time is a problem perhaps the core group needs to add resources
>> to reasonably address the problems in R. Traditional economics
>> do not apply to an open source project. There is no monetary cost to
>> adding additional developers.
>>>
>>> luke
>>>
>>> On Fri, 3 Oct 2008, Gabor Grothendieck wrote:
>>>
>>>> On Fri, Oct 3, 2008 at 3:23 AM, Martin Maechler
>>>> <maechler_at_stat.math.ethz.ch> wrote:
>>>>>
>>>>> a much better (and much less error-prone) idea would be to install
>>>>> R 2.8.0 alpha even now.
>>>>> It will become 'beta' early next week.
>>>>>
>>>>> We are asking the R community to please install and use
>>>>> pre-release versions of R (if you can / are allowed to)
>>>>> at least from beta onwards, and report problems you see early on
>>>>> *before* the final release.
>>>>
>>>> The bug discussed in the following year-old post suggested that
>>>> the problem of clobbering attributes of top level environment objects
>>>> would be fixed for 2.7 but its still in R version 2.7.2 (2008-08-25)"
>>>> and also still in "R version 2.8.0 alpha (2008-10-01 r46589)"
>>>>
>>>> https://stat.ethz.ch/pipermail/r-devel/2007-October/047184.html
>>>>
>>>> The Avoiding R Bugs section of this page:
>>>>
>>>> http://r-proto.googlecode.com
>>>>
>>>> has more discussion as well as a list of some other R bugs.
>>>>
>>>> This can be tested by creating a package with these two files only:
>>>>
>>>> ---DESCRIPTION---
>>>> Package: testlazy
>>>> Version: 1.0-0
>>>> Date: 2008-10-03
>>>> Title: Test lazy loading
>>>> Author: G Grothendieck
>>>> Maintainer: G Grothendieck <ggrothendieck_at_gmail.com>
>>>> Description: Test lazy loading with top level objects.
>>>> Depends: proto
>>>> LazyLoad: yes
>>>> License: GPL-2
>>>> ---R/testlazy.R---
>>>> TopLevel <- proto()
>>>> ---
>>>>
>>>> And then testing it:
>>>>
>>>> library(testlazy)
>>>> class(TopLevel)
>>>>
>>>> If its class is "environment" only then the class attribute was
>>>> stripped.
>>>>
>>>> ______________________________________________
>>>> R-devel_at_r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>>
>>>
>>> --
>>> Luke Tierney
>>> Chair, Statistics and Actuarial Science
>>> Ralph E. Wareham Professor of Mathematical Sciences
>>> University of Iowa Phone: 319-335-3386
>>> Department of Statistics and Fax: 319-335-3017
>>> Actuarial Science
>>> 241 Schaeffer Hall email: luke_at_stat.uiowa.edu
>>> Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
>>>
>>
>
> --
> Luke Tierney
> Chair, Statistics and Actuarial Science
> Ralph E. Wareham Professor of Mathematical Sciences
> University of Iowa Phone: 319-335-3386
> Department of Statistics and Fax: 319-335-3017
> Actuarial Science
> 241 Schaeffer Hall email: luke_at_stat.uiowa.edu
> Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri 03 Oct 2008 - 17:30:12 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 03 Oct 2008 - 22:30:16 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