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.
Herve Pages wrote:> ... > > > 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" >oops, please replace by> sessionInfo()R version 2.5.0 Under development (unstable) (2006-10-20 r39686) 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" sorry,> No problem with R-2.4.0. >This is still true. H.
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 > >