Re: [Rd] Overloading methods in R

2005-04-22 Thread Ali -
From: "A.J. Rossini" <[EMAIL PROTECTED]> You are mixing S3 and S4 paradigms. You want setMethod to define the method, not the FunctionName.ClassOfObject S3 specification. That just proves my newbie-ness in R programming. I would appreciate it if you could provide me the S4 equivalent. According

Re: [Rd] Overloading methods in R

2005-04-21 Thread Gabor Grothendieck
On 4/21/05, Ali - <[EMAIL PROTECTED]> wrote: > > > > > > > >f <- function(...) UseMethod("f", NULL) > > > >f.NULL <- function(...) { > > args <- list(...) > > classes <- sapply(args, class) > > .Class <- paste(classes, collapse = ".") > > NextMethod("f", ...) > >} > > > >f.numeric <- function(..

Re: [Rd] Overloading methods in R

2005-04-21 Thread Ali -
f <- function(...) UseMethod("f", NULL) f.NULL <- function(...) { args <- list(...) classes <- sapply(args, class) .Class <- paste(classes, collapse = ".") NextMethod("f", ...) } f.numeric <- function(...) 2 * ..1 f.numeric.numeric <- function(...) ..1 + ..2 f.char

Re: [Rd] Overloading methods in R

2005-04-21 Thread Gabor Grothendieck
On 4/21/05, Ali - <[EMAIL PROTECTED]> wrote: > > >> > >>- How to overload methods in classes created by R.oo package? > >[snip] > > > >Maybe you missed it in the flurry of messages, but did the idea suggested > >by Gabor Grothendick not suit your needs? > > I had to abstract the question in a set

Re: [Rd] Overloading methods in R

2005-04-21 Thread Ali -
- How to overload methods in classes created by R.oo package? [snip] Maybe you missed it in the flurry of messages, but did the idea suggested by Gabor Grothendick not suit your needs? I had to abstract the question in a setntence this time to prevent it to be missed again 'in the flurry of mess

RE: [Rd] Overloading methods in R

2005-04-21 Thread Jeff Gentry
On Thu, 21 Apr 2005, Henrik Bengtsson wrote: > > But what is wrong with: > > setGeneric("testFun", function(object, ...)) > Naming conflicts, may be the problem. You have that generic in your package, > but I might, without know about yours, and I write > setGeneric("testFun", function(x, ...))

RE: [Rd] Overloading methods in R

2005-04-21 Thread Henrik Bengtsson
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Gentry > Sent: Thursday, April 21, 2005 9:22 PM > To: Ali - > Cc: r-devel@stat.math.ethz.ch > Subject: RE: [Rd] Overloading methods in R > > > > On Thu, 21 A

RE: [Rd] Overloading methods in R

2005-04-21 Thread Henrik Bengtsson
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Tony Plate > Sent: Thursday, April 21, 2005 9:11 PM > To: Ali - > Cc: [EMAIL PROTECTED]; r-devel@stat.math.ethz.ch > Subject: Re: [Rd] Overloading methods in R > >

RE: [Rd] Overloading methods in R

2005-04-21 Thread Jeff Gentry
On Thu, 21 Apr 2005, Ali - wrote: > I guess the context says you cannot have something like this in S4: > >setGeneric("testFun", function(...) > + standardGeneric("testFun")) But what is wrong with: setGeneric("testFun", function(object, ...)) Keeping in mind that 'object' is the actual instant

Re: [Rd] Overloading methods in R

2005-04-21 Thread Tony Plate
Ali - wrote: Henrik, [snip] > Finally, I remind the package author about the original question: - How to overload methods in classes created by R.oo package? [snip] Maybe you missed it in the flurry of messages, but did the idea suggested by Gabor Grothendick not suit your needs? I don't know th

RE: [Rd] Overloading methods in R

2005-04-21 Thread Ali -
On Thu, 21 Apr 2005, Ali - wrote: > >However, in S3 you can create a "generic" generic function by not > >specifying > >arguments but only '...' - this way any methods can take any arguments (and > >you don't force your argument names onto other developer's). > So why did they go a step backward

RE: [Rd] Overloading methods in R

2005-04-21 Thread Jeff Gentry
On Thu, 21 Apr 2005, Ali - wrote: > >However, in S3 you can create a "generic" generic function by not > >specifying > >arguments but only '...' - this way any methods can take any arguments (and > >you don't force your argument names onto other developer's). > So why did they go a step backward

Re: [Rd] Overloading methods in R

2005-04-21 Thread A.J. Rossini
On 4/21/05, Ali - <[EMAIL PROTECTED]> wrote: > Thanks a lot for the reply Henrik. > > I do not know what was the motivation of R developers to go for yet another > OO design, but I wish the designers would have thought of ways to interface > this design to the other designs. Depends on which OO d

RE: [Rd] Overloading methods in R

2005-04-21 Thread Ali -
Thanks a lot for the reply Henrik. I do not know what was the motivation of R developers to go for yet another OO design, but I wish the designers would have thought of ways to interface this design to the other designs. As a wrapper developer, I like packages like R.oo not because it uses S3,

RE: [Rd] Overloading methods in R

2005-04-21 Thread Henrik Bengtsson
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Ali - > Sent: Thursday, April 21, 2005 1:28 PM > To: [EMAIL PROTECTED] > Cc: r-devel@stat.math.ethz.ch > Subject: RE: [Rd] Overloading methods in R > > > Henrik, > &

RE: [Rd] Overloading methods in R

2005-04-21 Thread Ali -
some 'answer'. -Ali Hi. Some clarification on R.oo: > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of A.J. Rossini > Sent: Wednesday, April 20, 2005 6:21 PM > To: Ali - > Cc: r-devel@stat.math.ethz.ch > Subject: Re: [R

RE: [Rd] Overloading methods in R

2005-04-21 Thread Henrik Bengtsson
Hi. Some clarification on R.oo: > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of A.J. Rossini > Sent: Wednesday, April 20, 2005 6:21 PM > To: Ali - > Cc: r-devel@stat.math.ethz.ch > Subject: Re: [Rd] Overloading methods in R

RE: [Rd] Overloading methods in R

2005-04-20 Thread Latchezar Dimitrov
Hello, > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] 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

Re: [Rd] Overloading methods in R

2005-04-20 Thread Gabor Grothendieck
On 4/20/05, Ali - <[EMAIL PROTECTED]> 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

Re: [Rd] Overloading methods in R

2005-04-20 Thread Martin Maechler
> "Ali" == Ali - <[EMAIL PROTECTED]> > on Wed, 20 Apr 2005 15:45:09 + writes: Ali> Thanks a lot Tony. I am trying to apply the overloading Ali> to the methods created by R.oo package and, Ali> unfortunately, R.oo uses S3-style classes; so I cannot Ali> use the featu

Re: [Rd] Overloading methods in R

2005-04-20 Thread Seth Falcon
"Ali -" <[EMAIL PROTECTED]> writes: > On the other hand, I caouldn't find a decent OO package which is > based on S4 AND comes with the official release of R. The OO system that comes with R and is based on S4 *is* S4. The challenge is that it is a different way of doing OO as compared to Java.

Re: [Rd] Overloading methods in R

2005-04-20 Thread A.J. Rossini
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, which is different. While the R documentation for S4 classes is quite useful (spanning the

Re: [Rd] Overloading methods in R

2005-04-20 Thread Ali -
Thanks a lot Tony. I am trying to apply the overloading to the methods created by R.oo package and, unfortunately, R.oo uses S3-style classes; so I cannot use the features of S4 methods as you described. On the other hand, I caouldn't find a decent OO package which is based on S4 AND comes with

Re: [Rd] Overloading methods in R

2005-04-20 Thread Tony Plate
If I understand what you are looking for, I believe your assumption (1) is FALSE, not TRUE as you suspected. One thing to realize is that "methods" in R are very different to those in other common "object-oriented" languages such as C++, Java, or Python. One difference is that methods are not

Re: [Rd] Overloading methods in R

2005-04-20 Thread Ali -
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

Re: [Rd] Overloading methods in R

2005-04-20 Thread Sean Davis
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