equivalent of $this
1
0
Entering edit mode
@textoris-julien-1412
Last seen 10.3 years ago
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
• 976 views
ADD COMMENT
0
Entering edit mode
@kasper-daniel-hansen-2979
Last seen 18 months ago
United States
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 >
ADD COMMENT
0
Entering edit mode
>>>>> "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
ADD REPLY

Login before adding your answer.

Traffic: 304 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6