Re: [Rd] LazyLoad changes the class of objects
On Wed, Oct 17, 2007 at 8:59 AM, Luke Tierney l...@stat.uiowa.edu wrote: Yes, attributes are not preserved, though why that should matter given the frequent strong recommendations in this list against using attributes on environments or other reference objects is beyond me. More importantly, locking and active bindings are not preserved either. Will look into fixing this this 2.7. 1. The above message from 2007 was about the possibility of fixing the fact that attributes on top level environments are stripped if LazyLoad: yes in a package's DESCRIPTION file. (They are not stripped if LazyLoad: false so that case works as expected -- its only the LazyLoad: true case that has this behavior.) Can this be finally fixed? 2. There was an R News article at the time that mentioned an undocumented 25K code size threshold that determined whether LazyLoad was turned on or off in those cases where LazyLoad was not specified in the DESCRIPTION file. Is that still the case? If not then what is the default? Its not mentioned in the R-ext manual. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] LazyLoad changes the class of objects
Yes, attributes are not preserved, though why that should matter given the frequent strong recommendations in this list against using attributes on environments or other reference objects is beyond me. More importantly, locking and active bindings are not preserved either. Will look into fixing this this 2.7. luke On Fri, 12 Oct 2007, Gabor Grothendieck wrote: Consider a package that this DESCRIPTION file: --- Package: tester Version: 0.1-0 Date: 2007-10-12 Title: Prototype object-based programming Author: Gabor Grothendieck Maintainer: Gabor Grothendieck [EMAIL PROTECTED] Description: test LazyLoad: true Depends: R (= 2.6.0) License: GPL2 --- and a single subdirectory R containing tester.R which contains two lines: --- e - new.env() class(e) - c(x, environment) --- Now issue these commands: library(tester) class(tester::e) [1] environment R.version.string # Windows Vista [1] R version 2.6.0 Patched (2007-10-08 r43124) Note that the class of e was changed from what we set it to !!! On the other handn, if we omit LazyLoad: true from the DESCRIPTION file then it retains its original class. # removed LazyLoad: true line from DESCRIPTION and reinstall pkg # now its ok library(tester) class(tester::e) [1] x environment __ R-devel@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 andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] LazyLoad changes the class of objects
Yes (on the yes), to second Luke. Here is John Chambers' comment when I was bitten by the same bug a while ago: http://tolstoy.newcastle.edu.au/R/devel/02b/0524.html See also Peter Dalgaard's follow up suggesting to wrap up the environment in a list, which will typically be enough. I've been using this trick successfully in the Object class (R.oo package) for several years, where I'm putting the environment in the attributes list of an object, i.e. obj - NA; attr(NA, ..env) - new.env(); It turned out at the time that this was slightly faster to access than using a list element. Cheers Henrik On 10/17/07, Luke Tierney [EMAIL PROTECTED] wrote: Yes, attributes are not preserved, though why that should matter given the frequent strong recommendations in this list against using attributes on environments or other reference objects is beyond me. More importantly, locking and active bindings are not preserved either. Will look into fixing this this 2.7. luke On Fri, 12 Oct 2007, Gabor Grothendieck wrote: Consider a package that this DESCRIPTION file: --- Package: tester Version: 0.1-0 Date: 2007-10-12 Title: Prototype object-based programming Author: Gabor Grothendieck Maintainer: Gabor Grothendieck [EMAIL PROTECTED] Description: test LazyLoad: true Depends: R (= 2.6.0) License: GPL2 --- and a single subdirectory R containing tester.R which contains two lines: --- e - new.env() class(e) - c(x, environment) --- Now issue these commands: library(tester) class(tester::e) [1] environment R.version.string # Windows Vista [1] R version 2.6.0 Patched (2007-10-08 r43124) Note that the class of e was changed from what we set it to !!! On the other handn, if we omit LazyLoad: true from the DESCRIPTION file then it retains its original class. # removed LazyLoad: true line from DESCRIPTION and reinstall pkg # now its ok library(tester) class(tester::e) [1] x environment __ R-devel@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 andFax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: [EMAIL PROTECTED] Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] LazyLoad changes the class of objects
On 10/17/07, Henrik Bengtsson [EMAIL PROTECTED] wrote: Yes (on the yes), to second Luke. Here is John Chambers' comment when I was bitten by the same bug a while ago: http://tolstoy.newcastle.edu.au/R/devel/02b/0524.html See also Peter Dalgaard's follow up suggesting to wrap up the environment in a list, which will typically be enough. I've been using this trick successfully in the Object class (R.oo package) for several years, where I'm putting the environment in the attributes list of an object, i.e. obj - NA; attr(NA, ..env) - new.env(); It turned out at the time that this was slightly faster to access than using a list element. This has all been discussed before but this trick is not sufficient for defining an environment subclass because it does not respect inheritance. The subclass writer must replicate all methods that act on environments in a subclass for an environment subclass to have them. Inheritance is completely broken. If there were N environment methods the writer of an environment subclass would have to write N methods to support them all. On the other hand, if it worked in a true OO way the subclass writer would not have to write anything. Also suppose a new environment method comes along. In true OO the subclass automatically inherits it but with the trick the subclass writer needs to write a new method always mimicing the parent. This is not how OO is supposed to work. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] LazyLoad changes the class of objects
Consider a package that this DESCRIPTION file: --- Package: tester Version: 0.1-0 Date: 2007-10-12 Title: Prototype object-based programming Author: Gabor Grothendieck Maintainer: Gabor Grothendieck [EMAIL PROTECTED] Description: test LazyLoad: true Depends: R (= 2.6.0) License: GPL2 --- and a single subdirectory R containing tester.R which contains two lines: --- e - new.env() class(e) - c(x, environment) --- Now issue these commands: library(tester) class(tester::e) [1] environment R.version.string # Windows Vista [1] R version 2.6.0 Patched (2007-10-08 r43124) Note that the class of e was changed from what we set it to !!! On the other handn, if we omit LazyLoad: true from the DESCRIPTION file then it retains its original class. # removed LazyLoad: true line from DESCRIPTION and reinstall pkg # now its ok library(tester) class(tester::e) [1] x environment __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel