From jmc at r-project.org  Fri Oct 27 15:16:45 2006
From: jmc at r-project.org (John Chambers)
Date: Fri, 27 Oct 2006 09:16:45 -0400
Subject: [Rd] S4 pb in R 2.5.0
In-Reply-To: <4541260F.9020507@fhcrc.org>
References: <4541260F.9020507@fhcrc.org>
Message-ID: <454206BD.70605@r-project.org>

Thanks for the typo, it might have taken a while to find this one otherwise!

In 2.5.0 and 2.4patched, the subclass information attempts to be 
complete.  That subclass information needs to be removed from all 
superclasses when the class is redefined, and currently isn't.  The 
particular superclass link to "vector" is what makes the code think that 
"A" is meant to be the data part of the new class.  When you redefined 
"A" to no longer contain "integer", that link should have gone away.

Looks fairly straightforward to fix but as with your other bug report, 
may not happen for a few days.


Herve Pages wrote:
> Hi,
>
> When playing interactively with the S4 system, I've tried
> to define the following class:
>
>     > setClass("A", representation("integer"))
>     [1] "A"
>     > showClass("A")
>      
>     Slots:
>                   
>     Name:    .Data
>     Class: integer
>      
>     Extends:
>     Class "integer", from data part
>     Class "vector", by class "integer", distance 2
>     Class "numeric", by class "integer", distance 2
>
> then I realized that I made a typo (I don't want to extend
> the "integer" type) so I redefined class A:
>
>     > setClass("A", representation(toto="integer"))
>     > showClass("A")
>     Slots:
>                   
>     Name:     toto
>     Class: integer
>
> Now if I try to extend A:
>
>     > setClass("Aa", representation("A"))
>     Error in reconcilePropertiesAndPrototype(name, slots, prototype,
>     superClasses,  :
>             "A" is not eligible to be the data part of another class
>     (must be a basic class or a virtual class with no slots)
>
> Surprising. And even more surprising: I don't get this if I don't
> try to define class A twice or if I invert the order of the 2 calls
> to setClass("A", ...)!
>
>     > sessionInfo()
>     R version 2.4.0 (2006-10-03)
>     x86_64-unknown-linux-gnu
>      
>     locale:
>     LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C
>      
>     attached base packages:
>     [1] "methods"   "stats"     "graphics"  "grDevices" "utils"    
>     "datasets"
>     [7] "base"
>
> No problem with R-2.4.0.
>
> Thanks,
> H.
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>




[Rd] S4 pb in R 2.5.0
John Chambers