Skip to content

Reimplement classes in S7 #6364

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

Open
wants to merge 107 commits into
base: main
Choose a base branch
from
Open

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Mar 17, 2025

This PR aims to fix a large part of #6352.

Briefly it implements the following S7 classes:

  • class_ggplot
  • class_ggplot_built
  • class_mapping
  • class_labels
  • class_theme

I've put in the usual extractors and replacers ([, [[, $ and their <- methods) for the ggplot/ggplot_built classes for backwards compatibility. The code internally now uses @ though, so that we can deprecate the usual extractors/replacers later.

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@teunbrand
Copy link
Collaborator Author

teunbrand commented Jun 5, 2025

I think it is necessary to make ggplot() a S3 generic again. I have the following reasons:

  1. Extension have S3 methods for the S3 generic.
    • You cannot write S3 methods for an S7 generic.
    • There are too many extensions to force them all to use S7 right now.
  2. Unlike S3 ggplot_build(), which we plan to replace with S7 build_ggplot(), the ggplot() function is much more user-facing. I don't think we want to phase-out ggplot() for other function names.
  3. If people want to use S7 methods, they can register them for the S3 generic without any issues.

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 this pull request may close these issues.

2 participants