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

Multiple dispatch for operators #1274

Open
eitsupi opened this issue Nov 3, 2024 · 3 comments
Open

Multiple dispatch for operators #1274

eitsupi opened this issue Nov 3, 2024 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@eitsupi
Copy link
Collaborator

eitsupi commented Nov 3, 2024

If multiple dispatches are to be achieved with S3 class methods, an approach such as the vctrs package may be necessary.

For example:

  • series + expr = expr
  • expr + series = expr
  • dataframe + series = dataframe
@eitsupi eitsupi added the enhancement New feature or request label Nov 3, 2024
@eitsupi eitsupi added this to the Rewrite milestone Nov 3, 2024
@eitsupi
Copy link
Collaborator Author

eitsupi commented Jan 17, 2025

Given that some packages are starting to adopt S7, is it worth adopting S7 rather than implementing our own multiple-dispatch thingy? (although of course we need to prioritize a rewrite based on savvy and rlang first)

@etiennebacher
Copy link
Collaborator

although of course we need to prioritize a rewrite based on savvy and rlang first

I agree with this, there are quite many things left to do in the rewrite so let's not add more complexity with this. It will be easier to weigh pros and cons once this big effort is finished.

But I'm interested in S7, I also need to learn more about it.

@eitsupi
Copy link
Collaborator Author

eitsupi commented Jan 17, 2025

Yes, of course, applying S7 right now would complicate things and should be avoided.

But given that the multiple dispatch of base R operators (+, etc.) seems quite incomplete, the adoption of S7 seems to be an advantage.
In my opinion, this feature is not that important and it may be better to hold off on implementing it until S7 is ready to be adopted.
https://rconsortium.github.io/S7/articles/generics-methods.html#multiple-dispatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants