-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Constraints for generics (generics details 3) #818
Conversation
Co-authored-by: Richard Smith <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not tried to do a complete or super detailed review, but I wanted to explicitly say I've gone through this at a high level and I'm really happy. The problems here are remarkably hard, and I feel like this is a really compelling set of solutions. I also think the analysis, explanation, comparisons, and alternatives are fantastic.
I've left a bunch of pretty minor comments as I went through. Many are really questions or ideas for the future, and completely not blocking. Others are optional or super minor. Don't wait on me for landing this. =D
Co-authored-by: Chandler Carruth <[email protected]>
Co-authored-by: Chandler Carruth <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm very happy with this.
@chandlerc, I think all the remaining unresolved comment threads are yours. I'm happy with you going ahead and approving once they're resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Co-authored-by: Chandler Carruth <[email protected]>
This proposal describes `where` clauses that can add constraints on a type-of-type, for example define restrictions on its associated types. Example: ``` fn FindFirstPrime[T:! Container where .Element = i32] (c: T) -> Optional(i32) { // The elements of `c` have type `T.Element`, which is `i32`. ... } fn PrintContainer[T:! Container where .Element is Printable](c: T) { // The type of the elements of `c` is not known, but we do know // that type satisfies the `Printable` interface. ... } ``` Some other constraints, such as `Sized` are defined as type-of-types directly, possibly parameterized. Co-authored-by: Richard Smith <[email protected]> Co-authored-by: Chandler Carruth <[email protected]>
This proposal describes
where
clauses that can add constraints on a type-of-type, for example define restrictions on its associated types. Example:Some other constraints, such as
Sized
are defined as type-of-types directly, possibly parameterized.