Skip to content

Pass ... to parent constructor#717

Open
hadley wants to merge 5 commits into
mainfrom
dots-constructor
Open

Pass ... to parent constructor#717
hadley wants to merge 5 commits into
mainfrom
dots-constructor

Conversation

@hadley

@hadley hadley commented Jun 24, 2026

Copy link
Copy Markdown
Member

There are two cases where it's not safe to re-use the deafults from the parent in a subclass constructor:

This does not make external parent classes entirely safe because it's possible the parent can make backward incompatible changes leading to run-time errors. But I think we believe that's outside of the scope of S7, and something that you'd discover when running your revdep checks prior to CRAN submission.

hadley added 5 commits June 24, 2026 09:04
There are two cases where it's not safe to re-use the deafults from the parent in a subclass constructor:

* When the parent comes from another package, because the specification might change between class construction and object instantaition. Fixes #317.
* When the parent constructor is custom, because we don't know anything about its environment. Fixes #609.

This does not make external parent classes entirely safe because it's possible the parent can make backward incompatible changes leading to run-time errors. But I think we believe that's outside of the scope of S7, and something that you'd discover when running your revdep checks prior to CRAN submission.
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.

Parent class constructor defaults are not safely scoped in child constructors Extending a class from another package

1 participant