-
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
if/else #285
if/else #285
Conversation
Proposal links (add links as proposal evolves):
|
proposals/p0285.md
Outdated
|
||
## Proposal | ||
|
||
We should make `if`/`else` syntax basically consistent with C/C++, rather than |
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 find "basically" to confuse this point. What is if anything is different from C++?
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.
Removing "basically", it's not a great word to add anyways.
I have no concerns. 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.
Should this also change the "provisional" text in the language overview?
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
This is just a proposal doc, and doesn't include design changes. Those would be handled separately, through code review. |
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.
This looks good.
Small request: could you add a few complete test programs and expected results (for addition to the testdata/ directory of the executable semantics).
Sorry, but I'd really rather not block this on changes to executable semantics. That is not a requirement, and honestly I'd rather just move forward (with the proposal). |
Hi Jon, My comment wasn't intended to block this... just meant as encouragement to collaborate with me on the executable semantics in parallel. I've added three test cases this afternoon... you might take a look to see if you think I've got the corner cases covered. |
LGTM for what it's worth. I'd personally probably go one step further and require
And none of the braces are optional. This is a strict subset of C++, with no further features. But it has no ambiguous else or goto-fail concerns or optional braces. That said, I am 100% fine with this proposal going in, and suggesting the above as a follow-up to restrict things unless Jon and others specifically want to narrow to this subset in this early proposal. |
Not a comment on the proposal, which is fine. Just to note in response to @chandlerc, if the braces are required, there's no need to require the parens. One nice effect that has is that C++ programmers' old instincts to put the parens in still creates legal code. |
Definitely an option, but not one I'd even want to consider here as that goes beyond simple sunsetting of C++. I'd suggest that and other extension like expression usage be later proposals. |
@dabrahams Regarding parentheses, please note the third bullet in the alternative:
(even if braces are required, this issue still applies, and thus parens should not be assumed to not be required) Also, please be careful not to @ people who are not part of Carbon ( |
@jonmeow could you explain where the Naturally @code was a typo. I will endeavor in future only to type the things I mean to type. |
Consider the parentheses-less code That can be interpreted as either An interesting, possibly more complex case of this is:
In either case, it's actually the difference between whether |
Co-authored-by: Geoff Romer <gromer@google.com>
Comment deadline set for March 9 -- ref https://forums.carbon-lang.dev/t/rfc-if-else-285/215/2 |
@jonmeow you're good to resolve and merge here |
@mmdriley Can you approve for commit? (proposals need a review manager's approval) |
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.
Ack! Sorry I was blocking this.
No description provided.