[R] help with oop in R - class structure and syntex

Henrik Bengtsson hb at stat.berkeley.edu
Tue Feb 5 17:03:48 CET 2008


On Feb 5, 2008 6:06 AM, Barry Rowlingson <b.rowlingson at lancaster.ac.uk> wrote:
> Duncan Murdoch wrote:
>
> > Another problem is that there are two different class systems in R:
> > sometimes calls S3 and S4 (because of the versions of S where they were
> > introduced).  You were reading about S3.
>
>   There's three different class systems if you also include the R.oo
> add-on package[1]. Even perl, the language seemingly founded on the
> concept of  TMTOWTDI[2], only has the one OOP system.

Not really, the R.oo package is using/promoting vanilla S3.  On top of
that, there is a root class Object that "inherits" the 'environment'
class (I use quotation marks, because you cannot/should not inherit
directly from the 'environment' class but wrap it up in a list
structure or similar; see R-devel threads on this).  Since the Object
class extend 'environment', instances of class Object can be passes by
reference, just like 'environment' objects.  It is that option of
passing objects by references that differ from common practices in R,
but I would say that is orthogonal to S3/S4 class system.  But yes,
this setup allows you to do OOP in a more Java/C++/... style.

Best,

Henrik

>
> Barry
>
> [1] http://www1.maths.lth.se/help/R/R.oo/
> [2] There's More Than One Way To Do It
>
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list