From sdavis2 at mail.nih.gov  Wed Apr 20 14:23:15 2005
From: sdavis2 at mail.nih.gov (Sean Davis)
Date: Wed Apr 20 14:23:24 2005
Subject: [Rd] Overloading methods in R
In-Reply-To: <BAY17-F138DB205C684A882E69EF3D12B0@phx.gbl>
References: <BAY17-F138DB205C684A882E69EF3D12B0@phx.gbl>
Message-ID: <51e673cd8d2702cf963930629b2fa87d@mail.nih.gov>


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


[Rd] Overloading methods in R
Sean Davis