-
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
Basic classes: use cases, struct literals, struct types, and future work #561
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.
Generally I think this is looking very good.
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.
LGTM
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.
Couple of super minor wording responses inline. Don't block on any of them though, ship it!
in line with avoiding global variables more generally. Carbon may need some | ||
support in this area, though, for parity with and migration from C++. | ||
|
||
### Computed properties |
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.
Sure. I just think we'll also want to consider non-computed properties. Anyways, no need to sweat the details of this section I think.
Co-authored-by: Chandler Carruth <[email protected]>
… (#699) This supports both struct type literals, `{.x: i32, .y: i32}`, and struct value literals, `{.x = 3, .y = 4}`. The degenerate case of `{}` is treated as a struct value literal, with the expectation that an empty struct value has the same type/value duality as an empty tuple value.
…ork (#561) This proposal defines the very basics of `class` types, primarily focused on: - use cases including: data classes, encapsulated types, inheritance with and without `virtual`, interfaces as base classes, and mixins for code reuse; - anonymous data types for called _structural data classes_ or _struct types_. Struct literals are used to initialize class values and ad-hoc parameter and return types with named components; and - future work, including the provisional syntax already in use for features that have not been decided. The intent is to both make some small incremental progress and get agreement on direction. As such it doesn't include things like nominal types, methods, access control, inheritance, etc. It proposes this struct type and literal syntax: ``` var p: {.x: Int, .y: Int} = {.x = 0, .y = 1}; ``` Note that it uses commas (`,`) between fields instead of semicolons (`;`), and no introducer for types or literal values. Incorporates decisions from #665 , #653 , #651 Co-authored-by: Geoff Romer <[email protected]> Co-authored-by: Chandler Carruth <[email protected]>
… (#699) This supports both struct type literals, `{.x: i32, .y: i32}`, and struct value literals, `{.x = 3, .y = 4}`. The degenerate case of `{}` is treated as a struct value literal, with the expectation that an empty struct value has the same type/value duality as an empty tuple value.
This proposal defines the very basics of
class
types, primarily focused on:virtual
, interfaces as base classes, and mixins for code reuse;The intent is to both make some small incremental progress and get agreement on direction. As such it doesn't include things like nominal types, methods, access control, inheritance, etc.
It proposes this struct type and literal syntax:
Note that it uses commas (
,
) between fields instead of semicolons (;
), and no introducer for types or literal values.Incorporates decisions from #665 , #653 , #651