Vitalie S. wrote: > Hello, > > Is there a way to access function's slots from inside the function? I > want to make functions slot dependent without recurring to generic > function mechanism.
Hi Vitalie -- See this recent thread in R-devel https://stat.ethz.ch/pipermail/r-devel/2009-June/053827.html > Probably this goes a bit against R philosophy, but otherwise I don't > really see the use of extending functions in R. One use is to allow for dispatch; it also provides a mechanism for formalizing attributes that one might like to associate with functions, e.g., their 'name'. In principle one could impose validity requirements, e.g., that they make no reference to global variables and other criteria, and hence are particularly suitable to parallel evaluation. > Would be nice to have something like: > > setClass("myFunc",list(type="numeric"),contains="function") > foo<-new("myFunc", > function(x) m...@type^x,type=0) Really here you're applying a function to an object, which is what generics and methods are for. Martin > > > Many thanks, > Vitalie. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.