pkgnet
pkgnet copied to clipboard
S4 and Reference class support in Function Reporter
Currently, Function Reporter will find R6 class methods, but nothing special is being done for S4 or Reference classes.
We need to figure out:
-
Do we need to do something special, or do we find the methods for free because they are functions (like in S3)? I believe the answer is no for Reference classes, and maybe no for S4, but we should figure this out for sure.
-
If we need to do something special, implement that as a part of Function Reporter.
Hadley's Advanced R is a great resource for how S4 and Reference classes work.
S4
From research and testing with adding S4 methods in milne
:
- S4 has a system of dispatching generics and class methods, much like S3.
- Where it is different: These are explicitly registered with functions
setGeneric
andsetMethod
, instead of like S3 where they are defined implicitly by following a naming convention that then gets picked up by roxygen2 and registered.
- Where it is different: These are explicitly registered with functions
- Generic methods will show up as a function in the package namespace.
- Class methods do not show up directly in the package namespace.
- S4 methods have a dispatch table registered in the package namespace, e.g. for the generic
height
in packagemilne
:
getNamespace('milne')$`.__T__height:milne`
- This is an environment, containing the class methods. The names following the convention
class1#class2
where class1 and class2 are the names of the classes in the method signature.