Attempt S4 dispatch for intersect() and union(), maybe - alternative#307
Open
Attempt S4 dispatch for intersect() and union(), maybe - alternative#307
Conversation
This was referenced Mar 19, 2026
Collaborator
Author
|
Of course, documentation has to be added, but other than that we don't have to select S4 methods ourselves. WDYT? |
| unique(c(x, y)) | ||
| } | ||
| #' @exportMethod union | ||
| setMethod("union", signature(x="ANY", y="ANY"), union.integer64) |
Collaborator
There was a problem hiding this comment.
In {nanotime}, they leave this unspecified and therefore it becomes base::intersect().
Overall I might expect we remove this from methods:
if (!(is.integer64(x) || is.integer64(y))) return(base::...)
In favor of S4 dispatch handling that part. Then we only need to define for signature(x="integer64", y="ANY") and signature(x="ANY", y="integer64").
Also, is there any residual benefit of the S3 method once we add the S4 dispatch?
Collaborator
Author
|
Please have a look at the man page, because of the additional S4 method entries. Your approach in PR #305 does not have those, which is cleaner in an overview, but hides the added S4 dispatch capabilities of the set ops. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here I use
setMethodfor S3 classes to achieve a S4 dispatch. With this approach the regular S4 dispatch takes place and no consideration is necessary within our functions/methods.Let's see if this is better than PR #305 or not.