Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S4 and Reference class support in Function Reporter #197

Closed
jayqi opened this issue Mar 2, 2019 · 1 comment
Closed

S4 and Reference class support in Function Reporter #197

jayqi opened this issue Mar 2, 2019 · 1 comment

Comments

@jayqi
Copy link
Collaborator

jayqi commented Mar 2, 2019

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
Copy link
Collaborator Author

jayqi commented Mar 13, 2019

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.

@bburns632 bburns632 added bug and removed bug labels Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants