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

Missing (equivalent of) S3 / S4 methods(class = .) to get all generics for which there are <class>-methods #435

Open
mmaechler opened this issue Sep 6, 2024 · 3 comments

Comments

@mmaechler
Copy link
Collaborator

I was just mentioning methods(class = class(.)) in an e-mail advice on R-help.
I've advertized this in my intermediate-to-advanced R teaching as a way to help users get familiar with what they can do some
(in statistics) model fit or similar.
Note that methods(class=*) is even not at all perfect (as it only finds methods for the exact class signature, but not those from parent classes which also apply).

When S7 becomes "main stream" we'd be happy to instrument utils::methods() to also work for S7 classes, but that's definitely for later, and I think we should provide the functionality within S7.

@lawremi
Copy link
Collaborator

lawremi commented Sep 8, 2024

Might be tricky since the methods are stored on the generics, not in some global table. The output of methods(class=) has always been a little misleading, because it doesn't account for "intrinsically generic" functions that work on an object without dispatch (by delegating to generics).

@mmaechler
Copy link
Collaborator Author

Well, yes, we'd have to loop over all generics (and consider caching the result (in a later iteration)).
I'm really arguing that methods(class = *) is already very useful to help users get a grasp about a say a model fit object which they are newly using.
{Can you give examples of "intrinsically generic"? Do you mean primitive generics or generics that belong to GroupGenerics?}

@lawremi
Copy link
Collaborator

lawremi commented Sep 11, 2024

Sorry by intrinsically generic, I mean ordinary functions that delegate to generics or other polymorphic functions. Basically, polymorphism via delegation. An example is order(). It delegates to xtfrm() to achieve polymorphism, but it is not itself generic (for obvious reasons).

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

No branches or pull requests

2 participants