[Rd] super basic questions about S4 classes

A Zege andre.zege at gmail.com
Tue Apr 5 18:47:23 CEST 2011


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.



More information about the R-devel mailing list