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

Generics: Set associated constants using where constraints #1013

Merged
merged 11 commits into from
Jan 27, 2022
Merged

Generics: Set associated constants using where constraints #1013

merged 11 commits into from
Jan 27, 2022

Conversation

josh11b
Copy link
Contributor

@josh11b josh11b commented Jan 7, 2022

Change the syntax for setting the associated constants and types in an interface implementation for a type from using let declarations as in:

class Vector(T:! Type) {
  impl as Iterable {
    let ElementType:! Type = T;
    ...
  }
}

to using where clauses as in:

class Vector(T:! Type) {
  impl as Iterable where .ElementType = T {
    ...
  }
}

This is an attempt to simplify by removing redundancy, improve consistency by removing a use of let that was different than other examples, and better support forward declaration that a type implements an interface while retaining the information needed for type checking.

@josh11b josh11b added the proposal A proposal label Jan 7, 2022
@josh11b josh11b requested a review from a team January 7, 2022 23:32
@josh11b josh11b marked this pull request as ready for review January 12, 2022 01:29
@josh11b josh11b requested a review from a team as a code owner January 12, 2022 01:29
@josh11b josh11b requested a review from zygoloid January 12, 2022 01:29
@github-actions github-actions bot added the proposal rfc Proposal with request-for-comment sent out label Jan 12, 2022
docs/design/generics/details.md Outdated Show resolved Hide resolved
proposals/p1013.md Outdated Show resolved Hide resolved
proposals/p1013.md Outdated Show resolved Hide resolved
proposals/p1013.md Outdated Show resolved Hide resolved
proposals/p1013.md Outdated Show resolved Hide resolved
proposals/p1013.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.

Looks good to me; soliciting broader input before approval.

docs/design/generics/details.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.

Some somewhat random thoughts here, but generally I really like this. I think its a great simplification & fix of a nagging issue. Super happy.

docs/design/generics/details.md Show resolved Hide resolved
docs/design/generics/terminology.md Show resolved Hide resolved
proposals/p1013.md 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.

LGTM, approving mostly on @zygoloid 's review, but I also am really happy here. =]

@josh11b josh11b merged commit b1b9d98 into carbon-language:trunk Jan 27, 2022
@josh11b josh11b deleted the set branch January 27, 2022 19:18
@github-actions github-actions bot added proposal accepted Decision made, proposal accepted and removed proposal rfc Proposal with request-for-comment sent out labels Jan 27, 2022
@zygoloid zygoloid mentioned this pull request Apr 15, 2022
chandlerc pushed a commit that referenced this pull request Jun 28, 2022
Change the syntax for setting the associated constants and types in an interface implementation for a type from using `let` declarations as in:
```
class Vector(T:! Type) {
  impl as Iterable {
    let ElementType:! Type = T;
    ...
  }
}
```
to using `where` clauses as in:
```
class Vector(T:! Type) {
  impl as Iterable where .ElementType = T {
    ...
  }
}
```

This is an attempt to simplify by removing redundancy, improve consistency by removing a use of `let` that was different than other examples, and better support forward declaration that a type implements an interface while retaining the information needed for type checking.

Co-authored-by: Richard Smith <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal accepted Decision made, proposal accepted proposal A proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants