[Rd] super basic questions about S4 classes

From: A Zege <andre.zege_at_gmail.com>
Date: Tue, 05 Apr 2011 11:47:23 -0500 (CDT)


Apologies for asking something that is probably super obvious, i just started with S4 classes and i guess i am not finding documentation that layout the grammar rules and give enough examples. Some questions i am having are these

  1. I understand that main method of writing a member function is to write a generic function and setMethod for this particular object. This, however, presumes that there is "virtuality" for this function, i.e. it could be used with other inherited classes . Truth is, many, if not most of my functions don't have virtuality in mind. I want to write them inside classes to achieve incapsulaton only -- use class member data without passing it as parameters or making global to a bunch of functions and have some specific class member functions that don't pollute a global namespace and can be called only for a particular class. This is what i know how to do with enclosures in R. Is there some obvious way of setting this environment local to a class without writing generic functions that i am missing?
  2. Is it possible to overload functions in other ways than having default parameter values and prototypes? For example, can i have two constructors with completely different sets of parameters?
  3. Is there some good way to debug S4 classes? I am very fond of mtrace() from debug package, but the simple set of commands i normally use doesn't take me into class methods.

Would appreciate any pointers on these..

--
View this message in context: http://r.789695.n4.nabble.com/super-basic-questions-about-S4-classes-tp3428591p3428591.html
Sent from the R devel mailing list archive at Nabble.com.

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 05 Apr 2011 - 16:50:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Apr 2011 - 11:30:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive