-
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
Inheritance #777
Inheritance #777
Conversation
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.
Got a first pass over this. Mostly trying to clarify wording, generally very happy with the direction here. A few places with more substantial changes, but nothing that I think is changing the direction at all (and give a shout if I've said anything that gives a different impression).
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
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 think this is basically good to go. I'd like to double check that others aren't interested in digging into it before it lands, and I'd like to officially close the blocking issues, but not seeing anything major left.
I suspect we may have some follow-up changes to tweak things, but I don't think that should hold up this version landing.
Couple of minor wording suggestions below, but none of these are really big issues, just me attempting to improve clarity.
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
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.
Minor tweak below. LGTM with that, and 🎉🎉🎉 for inheritance landing!
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This proposal adds inheritance to classes, following this syntax: ``` // Abstract classes may not be instantiated, but // may have abstract methods and be extended. abstract class AbstractBaseClass { virtual fn CanBeOverridden[me: Self]() -> i32 { return me.data; } abstract fn PureVirtual[me: Self]() -> i32; fn Create(data: i32) -> partial Self { return {.data = data}; } protected var data: i32; } // Classes are final by default class FinalClass extends AbstractBaseClass { impl fn PureVirtual[me: Self]() -> i32 { return me.x; } fn Create(data: i32) -> Self { return {.base = AbstractBaseClass.Create(data), .x = 2 * data}; } private var x: i32; } // Can be instantiated and extended base class ExtensibleClass { // May optionally use partial types in factory functions protected fn CreateAsBase(data: i32) -> partial Self { ... } fn Create(data: i32) -> Self { ... } } ``` Co-authored-by: Chandler Carruth <chandlerc@gmail.com> Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This proposal adds inheritance to classes, following this syntax: