-
Notifications
You must be signed in to change notification settings - Fork 86
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
C# 6.0 feature: expression bodied members #4
Conversation
@jskeet This one is also ready for committee 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.
Looks okay to me apart from the inconsistency Nigel has spotted (and the grammar line).
standard/classes.md
Outdated
The *accessor_declarations*, which shall be enclosed in "`{`" and "`}`" tokens, declare the accessors ([§15.7.3](classes.md#1573-accessors)) of the property. The accessors specify the executable statements associated with reading and writing the property. | ||
A *property_body* may either consist of an ***accessor body*** or an expression body ([§15.6.1](classes.md#1561-general)). In an accessor body, *accessor_declarations*, which shall be enclosed in "`{`" and "`}`" tokens, declare the accessors ([§15.7.3](classes.md#1573-accessors)) of the property. The accessors specify the executable statements associated with reading and writing the property. | ||
|
||
An expression body consisting of `=>` followed by an *expression* `E` and a semicolon is exactly equivalent to the statement body `{ get { return E; } }`, and can therefore only be used to specify getter-only properties where the result of the getter is given by a single expression. |
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.
Note to self: this is correct because we're only updating to C# 6. In C# 7 of course, there can be expression-bodied setters as well.
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.
We discussed "statement body" vs "block body" and decided to go for "block body" unless there's an objection. We should fix 12.16.1 to refer to block bodies as well (in the example comment) Possible reasons to not do this:
We will make sure we get fuller approval than usual (in particular @gafter, please comment) in case there are good reasons we've missed. |
abb347f
to
884adc7
Compare
I don't think there have been any changes since the last meeting - so this meeting, let's just make sure we have concrete plans. |
Next work for @BillWagner:
|
Co-authored-by: Jon Skeet <jonskeet@google.com>
4a5f7fe
to
ca48fb1
Compare
@Nigel-Ecma @jskeet All changes requested have been applied in the Classes clause. I did not change 12.6.1 (Expressions, anonymous functions, general). The term body is used in the grammar in that clause. I think we can replace it with statement, and replace "block body" with "statement body" in the subsequent paragraph. If we agree, I'll make that change. Otherwise this should be ready to merge and mark as complete for V6. |
That should not have been included.
Thanks Bill. I now can't find the right comment to reply to... and I'm confused about why I saw it still with |
I think you're last comment is correct: The grammar should include the (On the other note about finding the conversations: When I make the update, I 'resolve' the conversation, which hides it in the UI. You can "view resolved conversation" to see them, then you can un-resolve as well. |
|
@Nigel-Ecma: I think it would be better to use "block body" everywhere that we're referring to something with a block. What's your reasoning for preferring "statement body" in some places? |
No preference, I assumed I'd missed something... Jon while your Feb 11 comment above records the decision was to go with block body; it includes the note "Statement-bodied lambda" is a somewhat-well-known-phrase... When I came to review I noted that the edit was the other way around so I assumed that note or something else had made the decision go the other way, something I don't recall but could have forgotten, so I just checked the edit was consistent and nothing missed. I don't have a strong preference either way, just that it must be consistent, which it now is. Bill? |
Right - I think @BillWagner took things in the opposite direction of what I'd expected. (Thanks for spotting this.) We were definitely looking to make "block body" the canonical term, as per an email I sent on Feb 11th:
|
Good catch. I did reverse that. I'll update this PR now. |
I'd reversed the committee's decision in the previous commit
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.
Now is consistent the other way around :-)
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.
Very nearly there - just a couple of nits.
Co-authored-by: Jon Skeet <jonskeet@google.com>
Enable members to be expressions in addition to block statements.