[Rd] virtual superclasses

From: Bart <kranstauber_at_orn.mpg.de>
Date: Tue, 29 May 2012 23:37:55 +0200

Dear List,

I'm exploring the use of class inheritance for a package were developing. I want to try to build on existing a class, i first want to extend this a bit using a virtual class and then extend this virtual class in multiple other classes. This would be similar to bar3 in the example below. Since there are nice functions for creating an object of the first superclass i would like to use that object for the initialization but somehow that fails with the error :"node stack overflow". How could i resolve this problem

Thanks in advance


> setClass("foo", representation(a="numeric"),prototype = list( a =
> setClass("bar", representation(b="numeric"))
> setClass("foo2",contains=c("foo") )
> setClass("foo3",contains=c("foo", "VIRTUAL") )
> setClass("foo4",contains=c("foo", "bar") )
> setClass("bar2",contains=c("foo2") )
> setClass("bar3",contains=c("foo3") )
> setClass("bar4",contains=c("foo4") )
> i<-new("foo",a=1)
> new("bar2", i)

An object of class "bar2"
Slot "a":
[1] 1

> new("bar3", i)

Error in tryCatch(expr, error = function(e) { : node stack overflow
> new("bar4", i)

An object of class "bar4"
Slot "a":
[1] 1

Slot "b":
> sessionInfo()

R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-linux-gnu (64-bit)


  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
  [7] LC_PAPER=C                 LC_NAME=C
  [9] LC_ADDRESS=C               LC_TELEPHONE=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] tools_2.15.0

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 29 May 2012 - 21:52:35 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 30 May 2012 - 18:22:00 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive