Re: [Rd] Inspecting promises
Please keep in mind that while lazy evaluation and delayedAssign are documented parts of the language, promises are an internal implementation mechanism that is subject to change. In particular the fact that substitute behaves the way it does is a coincidence of the current implementation that may very well change. Currently, for example, the use of promises to make substitute work means promises need to be kept around once thei are forced. This is inefficient in several ways and may need to be fixed at some point. It may well be useful to provide some reflection mechanisms for examining environments, but there are more issues to consider than pending evaluations (active bindings for example). I'm not sure when this will rise to the top of anyone's priority list for implementation. luke On Sun, 23 Sep 2007, Gabor Grothendieck wrote: > Is there some way of displaying the expression and evaluation environment > associated with a promise? I have found the following: > >> # first run these two commands to set up example >> e <- new.env() >> delayedAssign("y", x*x, assign.env = e) > >> # method 1. shows expression but not evaluation environment >> str(as.list(e)) > List of 1 > $ y: promise to language x * x > >> # method 2. shows expression but not evaluation environment >> substitute(y, e) > x * x > > which shows two different ways of displaying the expression > associated with a promise but neither shows the evaluation > environment. The first technique may actually be a bug in > R based on previous discussion on r-devel. > > Is there a way to display both the expression and the evaluation > environment associated with a promise. Its a bit difficult to debug > code involving promises if you can't inspect the objects you are > working with. > >> R.version.string # Vista > [1] "R version 2.6.0 beta (2007-09-19 r42914)" > > __ > 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
[Rd] 'load' does not properly add 'show' methods for classes extending 'list'
The GeneSetCollection class in the Bioconductor package GSEABase extends 'list' > library(GSEABase) > showClass("GeneSetCollection") Slots: Name: .Data Class: list Extends: Class "list", from data part Class "vector", by class "list", distance 2 Class "AssayData", by class "list", distance 2 If I create an instance of this class and serialize it > x <- GeneSetCollection(GeneSet("X")) > x GeneSetCollection names: NA (1 total) > save(x, file="/tmp/x.rda") and then start a new R session and load the data object (without first library(GSEABase)), the 'show' method is not added to the appropriate method table. > load("/tmp/x.Rda") > x Loading required package: GSEABase Loading required package: Biobase Loading required package: tools Welcome to Bioconductor Vignettes contain introductory material. To view, type 'openVignette()'. To cite Bioconductor, see 'citation("Biobase")' and for packages 'citation(pkgname)'. Loading required package: AnnotationDbi Loading required package: DBI Loading required package: RSQLite An object of class "GeneSetCollection" [[1]] setName: NA geneIds: X (total: 1) geneIdType: Null collectionType: Null details: use 'details(object)' Actually, the behavior is more complicate than appears; in a new R session after loading /tmp/x.Rda, if I immediately do x[[1]] I get the show,GeneSetCollection-method but not show,GeneSet-method. Sorry for the somewhat obscure example. Martin -- Martin Morgan Bioconductor / Computational Biology http://bioconductor.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel