-
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
auto keyword for vars #851
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.
Sorry that this proposal got largely missed and not promptly reviewed.
I generally like the direction here. I've left one comment, but its pretty minor. I do want to check that the @carbon-language/carbon-leads don't want to see anything else here before moving forward or don't have any concerns.
Disadvantages: | ||
|
||
- Type inference becomes the _lack_ of a type, rather than the presence of | ||
something different. | ||
- C++'s syntax legacy may have needed `auto` in order to provide type | ||
inference, where Carbon does not. |
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 it'd be good to also capture that this creates the potential for ambiguity with expression patterns as well. There are possible ways of addressing that ambiguity (some of which you get into in the background section), but I feel like its still an important consideration in the tradeoff here. @zygoloid might even be able to suggest something here.
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.
Added a bullet for that, linking the background.
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.
Mid-air collision between your update and my suggestion. Here's what I'd written up (which looks similar enough to your new bullet):
Disadvantages: | |
- Type inference becomes the _lack_ of a type, rather than the presence of | |
something different. | |
- C++'s syntax legacy may have needed `auto` in order to provide type | |
inference, where Carbon does not. | |
Disadvantages: | |
- Type inference becomes the _lack_ of a type, rather than the presence of | |
something different. | |
- C++'s syntax legacy may have needed `auto` in order to provide type | |
inference, where Carbon does not. | |
- Removes syntactic distinction between binding of a new name and reference | |
to an existing name. Reintroducing this distinction would likely require | |
additional syntax, such as Swift's nested `let`. |
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.
Noting here -- replaced mine with @zygoloid's
Disadvantages: | ||
|
||
- Type inference becomes the _lack_ of a type, rather than the presence of | ||
something different. | ||
- C++'s syntax legacy may have needed `auto` in order to provide type | ||
inference, where Carbon does not. |
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.
Mid-air collision between your update and my suggestion. Here's what I'd written up (which looks similar enough to your new bullet):
Disadvantages: | |
- Type inference becomes the _lack_ of a type, rather than the presence of | |
something different. | |
- C++'s syntax legacy may have needed `auto` in order to provide type | |
inference, where Carbon does not. | |
Disadvantages: | |
- Type inference becomes the _lack_ of a type, rather than the presence of | |
something different. | |
- C++'s syntax legacy may have needed `auto` in order to provide type | |
inference, where Carbon does not. | |
- Removes syntactic distinction between binding of a new name and reference | |
to an existing name. Reintroducing this distinction would likely require | |
additional syntax, such as Swift's nested `let`. |
Co-authored-by: Richard Smith <[email protected]>
Co-authored-by: josh11b <[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.
LGTM, this looks really nice. =D
I was doing this for #851 initially, but I think #438 and #826 hadn't made it in (possibly intentionally due to #851? I don't recall). Co-authored-by: Chandler Carruth <[email protected]> Co-authored-by: Richard Smith <[email protected]>
Allow `var <identifier>: auto = <expression>;` syntax. Co-authored-by: Richard Smith <[email protected]> Co-authored-by: josh11b <[email protected]>
I was doing this for #851 initially, but I think #438 and #826 hadn't made it in (possibly intentionally due to #851? I don't recall). Co-authored-by: Chandler Carruth <[email protected]> Co-authored-by: Richard Smith <[email protected]>
Allow
var <identifier>: auto = <expression>;
syntax.