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

Group generics #353

Open
hadley opened this issue Sep 14, 2023 · 0 comments · May be fixed by #365
Open

Group generics #353

hadley opened this issue Sep 14, 2023 · 0 comments · May be fixed by #365
Milestone

Comments

@hadley
Copy link
Member

hadley commented Sep 14, 2023

Related to #320, we need some way to register methods for group generics. I think the syntax should probably look something like this?

library(S7)
foo <- new_class("foo", class_integer)
method(Math, foo) <- function(x) {
   foo(Math(super(x, class_integer)))
}
method(Ops, list(foo, class_any)) <- function(x, y) {
   foo(Ops(super(x, class_integer), y))
}
method(Ops, list(class_any, foo)) <- function(x, y) {
   foo(Ops(x, super(y, class_integer)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants