-
Notifications
You must be signed in to change notification settings - Fork 3
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
globalsOf() on locally defined S3 methods (fails) #2
Comments
Add c() and unique() for Globals class. Add internal utility functions isGenericS3(), s3GlobalsOf() and addS3Methods().
The There should also be similar tests added to the future package to make sure it works when such globals are exported and used in, e.g. external R sessions. There's also S4 generics/methods. How should/could we handle those? |
Related: How to find the location of "registered S3method for [[" methods? For example, > attr(methods("[["), "info")
visible from generic isS4
[[.bibentry FALSE registered S3method for [[ [[ FALSE
[[.data.frame TRUE base [[ FALSE
[[.Date TRUE base [[ FALSE
[[.dendrogram FALSE registered S3method for [[ [[ FALSE
[[.factor TRUE base [[ FALSE
[[.listenv FALSE registered S3method for [[ [[ FALSE
[[.numeric_version TRUE base [[ FALSE
[[.pdf_doc FALSE registered S3method for [[ [[ FALSE
[[.person FALSE registered S3method for [[ [[ FALSE
[[.POSIXct TRUE base [[ FALSE
[[.POSIXlt TRUE base [[ FALSE |
Moved to Issue #47 |
Background
globalsOf()
on locally defined S3 methods identifies the generic functions but not the corresponding S3 methods. This is not surprising.As long as the S3 methods are implemented in packages and those packages are loaded/attached, calling the generic function - as found by
globalsOf()
- will work. The S3 method to be dispatched on will be found at run time (since the class of the object needs to be known).Problem
However, if an S3 method is defined "locally" (e.g. in the global environment as part of prototyping/development), that S3 method will not be part of the set of globals that are exported to the job/task.
Workaround
The workaround is to:
methods(<generic>)
to search for all matching S3 methods.mth
to the list of globals.globalsOf(mth)
on added S3 method and repeat to make sure it also gets everything it needs.UPDATE 2016-04-10: This strategy can really only apply to
globalsOf()
and not tofindGlobals()
, because it's only with the former we retrieve objects and can inspect them for being generic functions or not.The text was updated successfully, but these errors were encountered: