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

Consistent class and interface syntax #2760

Merged
merged 23 commits into from
Jun 15, 2023
Merged

Conversation

josh11b
Copy link
Contributor

@josh11b josh11b commented Apr 12, 2023

Update syntax of class and interface definitions to be more consistent. Constructs that add names to the class or interface from another definition are always prefixed by the extend keyword.

Implements the decisions in:

@josh11b josh11b added proposal A proposal proposal draft Proposal in draft, not ready for review labels Apr 12, 2023
@josh11b josh11b marked this pull request as ready for review May 30, 2023 16:25
@josh11b josh11b removed the proposal draft Proposal in draft, not ready for review label May 30, 2023
@github-actions github-actions bot added the proposal rfc Proposal with request-for-comment sent out label May 30, 2023
@github-actions github-actions bot requested a review from KateGregory May 30, 2023 16:25
@josh11b
Copy link
Contributor Author

josh11b commented May 30, 2023

Please pay particular attention to the alternatives, I'm not sure that I have captured everything important we considered in #995 .

@josh11b
Copy link
Contributor Author

josh11b commented Jun 1, 2023

I have a draft PR #2866 for updating the syntax in the design docs, if you would like to see how this looks in a number of examples.

@josh11b josh11b requested review from zygoloid and removed request for KateGregory June 1, 2023 23:56
Copy link
Contributor

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

Thanks, this looks good and aligned with previous discussion and answers to questions-for-leads.

proposals/p2760.md Outdated Show resolved Hide resolved
proposals/p2760.md Outdated Show resolved Hide resolved
proposals/p2760.md Outdated Show resolved Hide resolved
proposals/p2760.md Outdated Show resolved Hide resolved
proposals/p2760.md Outdated Show resolved Hide resolved
proposals/p2760.md Show resolved Hide resolved
proposals/p2760.md Outdated Show resolved Hide resolved
proposals/p2760.md Outdated Show resolved Hide resolved
proposals/p2760.md Outdated Show resolved Hide resolved
proposals/p2760.md Outdated Show resolved Hide resolved
Copy link
Contributor

@chandlerc chandlerc left a comment

Choose a reason for hiding this comment

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

Haven't had time to fully work through, but wanted to at least respond to some of the open threads here.

proposals/p2760.md Outdated Show resolved Hide resolved
proposals/p2760.md Outdated Show resolved Hide resolved
Copy link
Contributor

@zygoloid zygoloid left a comment

Choose a reason for hiding this comment

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

Approving on behalf of leads. This reflects decisions from prior leads issues, with a scope reduction for require that @chandlerc and I are both happy with and that seems to generally improve consensus. Thanks!

@zygoloid zygoloid merged commit 6f8cf38 into carbon-language:trunk Jun 15, 2023
@josh11b josh11b deleted the syntax branch June 15, 2023 00:46
josh11b added a commit to josh11b/carbon-lang that referenced this pull request Jun 15, 2023
josh11b added a commit that referenced this pull request Jun 15, 2023
Implement syntax changes from #2760 in Explorer
josh11b added a commit that referenced this pull request Jun 16, 2023
This includes:

- Syntax changes from this chart:

| Before                          | After                                   |
| ------------------------------- | --------------------------------------- |
| `class D extends B { ... }`     | `class D { extend base: B; ... }`       |
| `external impl C as Sub;`       | `impl C as Sub;`                        |
| `class C { impl as Sortable; }` | `class C { extend impl as Sortable; }`  |
| `adapter A for C { ... }`       | `class A { adapt C; ... }`              |
| `adapter A extends C { ... }`   | `class A { extend adapt C; ... }`       |
| `interface I { impl as J; }`    | `interface I { require Self impls J; }` |
| `interface I { extends J; }`    | `interface I { extend J; }`             |

- Dropping the syntax for conditionally implemented internal interfaces.

This does not include:

- terminology changes from #2760 ("internal" and "external")
- changes to code, such as explorer, toolchain, language grammars, or other tooling
@josh11b josh11b mentioned this pull request Jun 16, 2023
josh11b added a commit to josh11b/carbon-lang that referenced this pull request Jun 17, 2023
josh11b added a commit that referenced this pull request Jun 19, 2023
- Renames `extends` -> `extend`
- Removes `external`
- Adds `require`

None of these seem to be in use by the parser yet, so no other changes are needed.
github-merge-queue bot pushed a commit that referenced this pull request Aug 2, 2023
This reflects changes from a number of approved proposals:
- #920 : concrete statements about orphan and overlap in Carbon
- #2138 : "generic" -> "checked generic", "template" -> "template
generic"
- #2188 : binding patterns are forbidden in type position
- #2360 : "type", "facet type", "facet". Note: I am not using the term
"generic type" from #2360 since that meaning conflicts with the
generally accepted meaning of "generic type" of a type with a
compile-time parameter.
- #2760 / #2770 : internal/external impl -> extending impl
- #2964 : "symbolic constant" and "template constant"

---------

Co-authored-by: Geoff Romer <[email protected]>
Co-authored-by: Richard Smith <[email protected]>
@josh11b josh11b mentioned this pull request Aug 3, 2023
github-merge-queue bot pushed a commit that referenced this pull request Aug 15, 2023
This reflects changes from a number of approved proposals:

- #2138 : "generic" -> "checked generic", "template" -> "template
generic"
- #2360 : "type", "facet type", "facet". Note: I am not using the term
"generic type" from #2360 since that meaning conflicts with the
generally accepted meaning of "generic type" of a type with a
compile-time parameter.
- #2760 / #2770 : internal/external impl -> extending impl
- #2964 : "symbolic constant" and "template constant"

---------

Co-authored-by: Richard Smith <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Sep 8, 2023
Incorporates proposals: #1885, #2138, #2188, #2200, #2360, #2760, #2964,
and #3162.

---------

Co-authored-by: Richard Smith <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Sep 23, 2023
Includes proposals:
- #990
- #2188
- #2138
- #2200
- #2360
- #2760
- #2964
- #3162

Also tries to use more precise language when talking about:
- implementations, to avoid confusing `impl` declaration and definitions
with the `impls` operator used in `where` clauses, an issue brought up
in #2495 and #2483;
- "binding patterns", like `x: i32`, and "bindings" like `x`.

---------

Co-authored-by: Chandler Carruth <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Oct 11, 2024
…4401)

Note: some of this is from the principle of information accumulation,
and some is from [proposal
#2760](https://github.com/carbon-language/carbon-lang/blob/trunk/proposals/p2760.md#class-inheritance).

Also: change terminology from "virtual override keywords" to "virtual
modifier keywords", to be consistent with our other modifier keywords.

---------

Co-authored-by: Josh L <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal rfc Proposal with request-for-comment sent out proposal A proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants