From ldimitro at wfubmc.edu  Wed Apr 20 21:30:54 2005
From: ldimitro at wfubmc.edu (Latchezar Dimitrov)
Date: Wed Apr 20 21:31:34 2005
Subject: [Rd] Overloading methods in R
Message-ID: <F160BE32A2E5E04497668BBDFE83FEDF08DA8250@EXCHVS1.medctr.ad.wfubmc.edu>

Hello, 

> -----Original Message-----
> From: r-devel-bounces@stat.math.ethz.ch 
> [mailto:r-devel-bounces@stat.math.ethz.ch] On Behalf Of A.J. Rossini
> Sent: Wednesday, April 20, 2005 12:21 PM
> To: Ali -
> Cc: r-devel@stat.math.ethz.ch
> Subject: Re: [Rd] Overloading methods in R
> 
> R.oo tries to implement an old-fashioned OO system as found 
> in Java, Python, C++, etc.  R's S4 methods implement a nice 
> modern system based on the generic function approach , 
> dispatch on argument signatures,

With all respect to R (and its developers) and for the records I
couldn't
help but refer to Ada'83 (not even '95 :-)) 

Best regards,

Latchezar Dimitrov

> which is different.
> 
> While the R documentation for S4 classes is quite useful 
> (spanning the green book, the BioC developer help pages,  
> V&R's book on programming, and some other papers), I've found 
> that for a nice background, Paul Graham's ANSI Lisp book, and 
> in particular the nicely written chapter on CLOS, provides a 
> nice introduction to the thought process.
> 
> With respect to the R.oo package, the author might be the 
> best source for that.
> 
> Another package which you might take a look at is the proto 
> package, which provides prototype object-orientation similar 
> to that found in XLispStat, and also might help with what you 
> are trying to do. 
> However, I suspect that learning about the S4 system will 
> provide more benefit in the future.
> 
> best,
> -tony
> 
> On 4/20/05, Ali - <saveez@hotmail.com> wrote:
> > Sean,
> > 
> > Thanks, but, I am actually talking about overloading 
> 'methods' and not 
> > 'functions', or you may want to answer this question: How 
> to overload 
> > methods in classes created by R.oo package?
> > 
> > >
> > >On Apr 20, 2005, at 8:16 AM, Ali - wrote:
> > >
> > >>(1) It seems to me that, generally, in R it is not possible to  
> > >>overload functions. Is that right?
> > >>
> > >>(2) Assuming that the above is true, or partially true, 
> is there any 
> > >>extra packages to handle overloading in R?
> > >>
> > >>(3) Assuming (1) is TRUE and (2) is FALSE, can anyone 
> provide some  
> > >>advice on developing some function that understand what the 
> > >>arguments  are and then calls the right overloaded function?
> > >>
> > >>It would be something like this:
> > >>
> > >>overloadedFunction1 <- function(x) {};
> > >>
> > >>overloadedFunction2 <- function(x, y) {};
> > >>
> > >>theFunction <- function(...)
> > >>{
> > >>   # How to identify ... and call the right overloaded function?
> > >>}
> > >>
> > >
> > >Ali,
> > >
> > >You are probably interested in "methods".  Functions can have 
> > >different "methods" depending on what the arguments and 
> their types 
> > >are.  A first place to look is:
> > >
> > 
> >http://cran.r-project.org/doc/manuals/R-exts.html#Generic-functions-
> > >and-methods
> > >
> > >Sean
> > >
> > 
> > ______________________________________________
> > R-devel@stat.math.ethz.ch mailing list 
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> > 
> 
> 
> --
> best,
> -tony
> 
> "Commit early,commit often, and commit in a repository from 
> which we can easily roll-back your mistakes" (AJR, 4Jan05).
> 
> A.J. Rossini
> blindglobe@gmail.com
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


[Rd] Overloading methods in R
Latchezar Dimitrov