Wacek Kusnierczyk wrote: > Martin Morgan wrote: > > [...] > >>> from a contiguous sequence of integers, starting at 1 (this doesn't seem >>> to be a particularly extravagant idea either): >>> >>> setClass('foo', representation(id='integer')) >>> setMethod('initialize', 'foo', local({ >>> id=0L >>> function(.Object, ...) { >>> id <<- id+1L >>> .obj...@id = id >>> return(.Object) } })) >>> >>> foos = replicate(3, new('foo')) >>> sapply(foos, slot, 'id') >>> # 1 2 3 >>> >>> setClass('bar', contains='foo', representation(name='character')) >>> setMethod('initialize', 'bar', function(.Object, name='bar', ...) { >>> .obj...@name = name >>> callNextMethod() }) >>> bars = replicate(3, new('bar')) >>> sapply(bars, slot, 'id') >>> # 6 7 8 >>> >>> what?? why on earth creating a subclass *calls* (twice!) the >>> superclass's initializer? is there no other way for checking the >>> >> once when the superclass is instantiated (fair enough!) > > fair? what's fair here? that just creating a subclass involves > instantiation of the superclass? makes little sense to me.
I completely misread your post, sorry. Martin ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.