Question: equivalent of $this 0 13.7 years ago by TEXTORIS Julien160 wrote: Hi, when programming with R and objects, when you describe a new class or method, does$this or an equivalent exists ? Sometimes, there is : function(Object) (So Object is something equivalent to $this ?) function(.Object) (and .Object too ?) function(x,i,j,...) (and in this case x was equivalent to$this) I saw the last case in a redifinition of an existing method for the new object created by myclass, and if i understand well, if a generic function was first described with function(x,i,j,...) one will reutilize it, instead, if it's a new function, one will use Object or either .Object ? Is that true ? thanks Julien
• 304 views
modified 13.7 years ago by Kasper Daniel Hansen6.4k • written 13.7 years ago by TEXTORIS Julien160
Answer: equivalent of $this 0 13.7 years ago by United States Kasper Daniel Hansen6.4k wrote: If it is a redefinition of an existing method it will (or rather it has to) use the arguments of the existing general method. If you make you own method, you choose what to call the arguments, but standard says to call it object if it is a method only accepting an object (or perhaps on object and a value) - at least when you use S4 classes. Kasper M, TEXTORIS Julien wrote: > Hi, > > when programming with R and objects, when you describe a new class or > method, does$this or an equivalent exists ? Sometimes, there is : > > function(Object) (So Object is something equivalent to $this ?) > function(.Object) (and .Object too ?) > function(x,i,j,...) (and in this case x was equivalent to$this) > > > I saw the last case in a redifinition of an existing method for the > new > object created by myclass, and if i understand well, if a generic > function was first described with function(x,i,j,...) one will > reutilize > it, instead, if it's a new function, one will use Object or > either .Object ? > > Is that true ? > > thanks > > Julien > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor >
>>>>> "Kasper" == Kasper Daniel Hansen <khansen at="" stat.berkeley.edu=""> >>>>> on Thu, 8 Sep 2005 21:32:16 -0700 writes: Kasper> If it is a redefinition of an existing method it Kasper> will (or rather it has to) use the arguments of the Kasper> existing general method. If you make you own method, Kasper> you choose what to call the arguments, but standard Kasper> says to call it object if it is a method only Kasper> accepting an object (or perhaps on object and a Kasper> value) - at least when you use S4 classes. which "standard"? I think it is "common usage" at most; I personally don't like that common usage so much and I'm rather naming my function arguments either more according to their contents, or then, for the first (few) arguments only, using much shorter names such as 'x', 'y', etc. Type library(fortune) # maybe after install.package("fortune") fortune("dog") for a funny variation on this theme... Martin Maechler, ETH Zurich Kasper> M, TEXTORIS Julien wrote: >> Hi, >> >> when programming with R and objects, when you describe a new class or >> method, does $this or an equivalent exists ? Sometimes, there is : >> >> function(Object) (So Object is something equivalent to$this ?) >> function(.Object) (and .Object too ?) >> function(x,i,j,...) (and in this case x was equivalent to \$this) >> >> >> I saw the last case in a redifinition of an existing method for the >> new >> object created by myclass, and if i understand well, if a generic >> function was first described with function(x,i,j,...) one will >> reutilize >> it, instead, if it's a new function, one will use Object or >> either .Object ? >> >> Is that true ? >> >> thanks >> >> Julien