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

are abstract / base specifiers permitted or required on class forward declarations? #3384

Closed
zygoloid opened this issue Nov 10, 2023 · 4 comments
Labels
leads question A question for the leads team

Comments

@zygoloid
Copy link
Contributor

zygoloid commented Nov 10, 2023

Summary of issue:

Given this class:

base class C {}

how does one write a forward declaration? Is

base class C;

valid? Is

class C;

valid?

Details:

There doesn't seem to be a reason to require the abstract or base specifier to be present on a forward declaration. But usually our forward declaration syntax for classes is a prefix of the definition, and there also doesn't seem to be any particular hardship to developers in requiring the forward declaration to repeat the specifier.

In addition to the three answers suggested by the question (specifier is disallowed, specifier is allowed but not required, specifier is required), we could change the class definition syntax to put the specifier in the class body, as we did for inheritance:

class C {
  base class;
  extend base: B;
}

Any other information that you want to share?

No response

@zygoloid zygoloid added the leads question A question for the leads team label Nov 10, 2023
github-merge-queue bot pushed a commit that referenced this issue Nov 13, 2023
)

For now, we require the same introducer to be used each time a class is
declared, but see #3384.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
@justzh

This comment was marked as off-topic.

@chandlerc
Copy link
Contributor

@justzh - Please keep comments on PRs and issues constructive and on-topic. I'm hiding yours, but you've had warnings now and so I will block if this continues.

@josh11b
Copy link
Contributor

josh11b commented May 21, 2024

This question was discussed at the end of open discussion on 2024-05-09. I believe the conclusions were:

  • modifiers on forward declarations should match those on extern declarations (except for the extern modifier)
  • otherwise prefer not repeating modifiers
  • prefer putting modifiers on definitions over forward declarations

@zygoloid
Copy link
Contributor Author

zygoloid commented Oct 8, 2024

This question was addressed by #3762 after consideration of alternatives:

  • Other class, impl, and interface modifiers (abstract, base, final) exist only on the definition, not on the forward declaration.

@zygoloid zygoloid closed this as completed Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
leads question A question for the leads team
Projects
None yet
Development

No branches or pull requests

4 participants