Skip to content
Prev 320203 / 398506 Next

From Java to R OOP

On Mon, Mar 25, 2013 at 6:51 AM, Francisco J. Bido <bido at mac.com> wrote:
Java is not the end-all of OOP (in fact S is a good bit older than
Java) and you might find that the Lisp or Dylan object systems are a
better analogy. (I'm only going by hearsay on Dylan; never used it
myself) You might also quickly breeze through:
https://github.com/hadley/devtools/wiki/S3
If you accept the immutability of objects, then arguably yes, I
suppose polymorphism gives you a great deal of it. The remaining
weaknesses are generally addressed by the S4 object system.

(Not immutability of bindings like Haskell, but the fact that x <- y
<- 1:5; y[3] <- 10 won't change x. In theory this is done by creating
a new y with the modified 3rd element and binding the name y to that;
not entirely thus in practice for performance reasons )
Grepping through R's source, it seems that the print system uses a
fair amount of NextMethod for the AsIs and noquote print methods. You
might take a look at those: also, section 7 of
http://cran.r-project.org/doc/manuals/r-devel/R-exts.html

MW