From dj at research.bell-labs.com  Tue Nov  4 15:23:05 2003
From: dj at research.bell-labs.com (David James)
Date: Tue Nov  4 15:22:52 2003
Subject: [Rd] Object saved from 1.7.1, loaded in 1.8.0
In-Reply-To: <8CBAA121CEB4D5118CB200508BB2BBEF05BF734F@xmx8lonib.lonib.commerzbank.com>;
	from Giles.Heywood@commerzbankib.com on Tue, Nov 04, 2003 at 08:30:37AM
	-0000
References: <8CBAA121CEB4D5118CB200508BB2BBEF05BF734F@xmx8lonib.lonib.commerzbank.com>
Message-ID: <20031104092305.A12006@jessie.research.bell-labs.com>

Hi,

Heywood, Giles wrote:
> I am having difficulty using in 1.8.0 an object created under 1.7.1. The
> following is a 'minimal example' of the issue.  First the part in 1.7.1:
> 
> > require("methods")
> [1] TRUE
> > setClass("foo",representation("vector",label="character"))
> [1] "foo"
> > x <- new("foo",1:2,label=LETTERS[1:2])
> > save(x,file="f:/temp/test_gh.171.Rdata")
> 
> Then in 1.8.0:
> 
> > require("methods")
> [1] TRUE
> > setClass("foo",representation("vector",label="character"))
> [1] "foo"
> > load("f:/temp/test_gh.171.Rdata")
> > new("foo",x,label=x@label)
> Error in initialize(value, ...) : Initialize method returned an object of
> class "foo" instead of the required class "foo"
> > new("foo",x@.Data,label=x@label)
> An object of class "foo"
> [1] 1 2
> Slot "label":
> [1] "A" "B"
> 
> > y <- new("foo",1:2,label=LETTERS[1:2])
> > new("foo",y,label=y@label)
> An object of class "foo"
> [1] 1 2
> Slot "label":
> [1] "A" "B"
> 
> > attributes(class(x))
> NULL
> > attributes(class(y))
> $package
> [1] ".GlobalEnv"
> 
> > attributes(class(x)) <- attributes(class(y))
> > new("foo",y,label=y@label)
> An object of class "foo"
> [1] 1 2
> Slot "label":
> [1] "A" "B"
> 
> As far as I can see, the "class" attribute now has an attribute "package",
> and the absence of this attribute in objects created under 1.7.1 causes the
> problem.  This lack of 'backward compatibility' has been flagged to me as a
> bug in the package 'its' that I maintain on CRAN.  I'm not sure it's a
> bug... should I advise users to re-generate their stored objects using e.g.
> new("foo",x@.Data,label=x@label)?  Or is there something I am missing
> altogether here?
> 
> TIA
> 
> Giles Heywood
> 
> OS: NT4
> 
> R.version
>          
> platform i386-pc-mingw32
> arch     i386           
> os       mingw32        
> system   i386, mingw32  
> status                  
> major    1              
> minor    8.0            
> year     2003           
> month    10             
> day      08             
> language R      
> 
> 
> ********************************************************************** 
> This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

I seem to have a very similar problem.   In my case I cannot use
R 1.8.0 to extend a base class in a package built under 1.7.1.
Namely, if I have installed the package DBI under 1.7.1 and attempt
to installed ROracle under 1.8.0  I get

R CMD check RORacle       ## R 1.8.0
.....
Error in .combineExtends(byExt, toExt, by, to) :
        No slot of name "subClass" for this object of class "SClassExtension"
Error in .combineExtends(byExt, toExt, by, to) :
        No slot of name "subClass" for this object of class "SClassExtension"
Error in setClass("OraDriver", representation("DBIDriver", "OraObject")) :
        Error in contained classes ("DBIDriver", "OraObject")
        for class "OraDriver"; class definition removed from "ROracle"
                           Execution halted
ERROR: execution of package source for 'ROracle'
                           failed

(I should also mention that the R 1.7.1 DBI installation above uses a
saved image.)

I'm aware that it is not a good idea to allow this type of version
mismatch, but I wouldn't be surprised if other unsuspecting users
get also bitten by it.

--
David


[Rd] Object saved from 1.7.1, loaded in 1.8.0
David James