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

Signature of return value of generic function? #523

Open
eitsupi opened this issue Jan 21, 2025 · 2 comments
Open

Signature of return value of generic function? #523

eitsupi opened this issue Jan 21, 2025 · 2 comments

Comments

@eitsupi
Copy link

eitsupi commented Jan 21, 2025

Wouldn't it be potentially useful in documentation and testing if we could set a class for the return value of a generic function?

For example, Rust defines a trait with a method as like:

pub trait Summary {
    fn summarize(&self) -> String;
}

In the absence of such a thing, I don't think we can rule out the possibility of completely different return values for each method.

For example, in the past, there has been some discussion about what the dplyr::pull() methods in the arrow package should return (apache/arrow#32705).
I imagine that if the return class of the dplyr::pull() generic function were defined, this confusion could be avoided.

@hadley
Copy link
Member

hadley commented Jan 21, 2025

How would such a constraint be enforced?

@eitsupi
Copy link
Author

eitsupi commented Jan 22, 2025

How would such a constraint be enforced?

I think it is the same issue as #450

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