pkgnet icon indicating copy to clipboard operation
pkgnet copied to clipboard

S4 and Reference class support in Function Reporter

Open jayqi opened this issue 6 years ago • 1 comments

Currently, Function Reporter will find R6 class methods, but nothing special is being done for S4 or Reference classes.

We need to figure out:

  1. 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.

  2. 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.

jayqi avatar Mar 02 '19 16:03 jayqi

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 and setMethod, instead of like S3 where they are defined implicitly by following a naming convention that then gets picked up by roxygen2 and registered.
  • 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 package milne:
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.

jayqi avatar Mar 13 '19 03:03 jayqi