You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid defining block body and expression body multiple times
Even though the precise context for the original definitions isn't
applicable other times, it's simpler to just leave those as the sole
definitions. The other uses are conceptually equivalent - it's not
like we're actually defining different terms.
Additionally, replace "statement body" with "block body" for both
properties and indexers.
Fixesdotnet#948.
Fixesdotnet#877.
Copy file name to clipboardExpand all lines: standard/classes.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -2027,7 +2027,7 @@ For abstract and extern methods, the *method_body* consists simply of a semicolo
2027
2027
2028
2028
If the *method_body* consists of a semicolon, the declaration shall not include the `async` modifier.
2029
2029
2030
-
The *ref_method_body* of a returns-by-ref method is either a semicolon, a ***block body*** or an ***expression body***. A block body consists of a *block*, which specifies the statements to execute when the method is invoked. An expression body consists of `=>`, followed by `ref`, a *variable_reference*, and a semicolon, and denotes a single *variable_reference* to evaluate when the method is invoked.
2030
+
The *ref_method_body* of a returns-by-ref method is either a semicolon, a block body or an expression body. A block body consists of a *block*, which specifies the statements to execute when the method is invoked. An expression body consists of `=>`, followed by `ref`, a *variable_reference*, and a semicolon, and denotes a single *variable_reference* to evaluate when the method is invoked.
2031
2031
2032
2032
For abstract and extern methods, the *ref_method_body* consists simply of a semicolon; for all other methods, the *ref_method_body* is either a block body or an expression body.
2033
2033
@@ -3168,15 +3168,15 @@ The *member_name* ([§15.6.1](classes.md#1561-general)) specifies the name of th
3168
3168
3169
3169
The *type* of a property shall be at least as accessible as the property itself ([§7.5.5](basic-concepts.md#755-accessibility-constraints)).
3170
3170
3171
-
A *property_body* may either consist of a ***statement body*** or an ***expression body***. In a statement 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.
3171
+
A *property_body* may either consist of a block body or an expression body. In a block 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.
3172
3172
3173
-
In a *property_body* 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 read-only properties where the result of the get accessor is given by a single expression.
3173
+
In a *property_body* an expression body consisting of `=>` followed by an *expression*`E` and a semicolon is exactly equivalent to the block body `{ get { return E; } }`, and can therefore only be used to specify read-only properties where the result of the get accessor is given by a single expression.
3174
3174
3175
3175
A *property_initializer* may only be given for an automatically implemented property ([§15.7.4](classes.md#1574-automatically-implemented-properties)), and causes the initialization of the underlying field of such properties with the value given by the *expression*.
3176
3176
3177
-
A *ref_property_body* may either consist of a statement body or an expression body. In a statement body a *get_accessor_declaration* declares the get accessor ([§15.7.3](classes.md#1573-accessors)) of the property. The accessor specifies the executable statements associated with reading the property.
3177
+
A *ref_property_body* may either consist of a block body or an expression body. In a block body a *get_accessor_declaration* declares the get accessor ([§15.7.3](classes.md#1573-accessors)) of the property. The accessor specifies the executable statements associated with reading the property.
3178
3178
3179
-
In a *ref_property_body* an expression body consisting of `=>` followed by `ref`, a *variable_reference*`V` and a semicolon is exactly equivalent to the statement body `{ get { return ref V; } }`.
3179
+
In a *ref_property_body* an expression body consisting of `=>` followed by `ref`, a *variable_reference*`V` and a semicolon is exactly equivalent to the block body `{ get { return ref V; } }`.
3180
3180
3181
3181
> *Note*: Even though the syntax for accessing a property is the same as that for a field, a property is not classified as a variable. Thus, it is not possible to pass a property as an `in`, `out`, or `ref` argument unless the property is ref-valued and therefore returns a variable reference ([§9.7](variables.md#97-reference-variables-and-returns)). *end note*
3182
3182
@@ -4198,13 +4198,13 @@ The *formal_parameter_list* specifies the parameters of the indexer. The formal
4198
4198
4199
4199
The *type* of an indexer and each of the types referenced in the *formal_parameter_list* shall be at least as accessible as the indexer itself ([§7.5.5](basic-concepts.md#755-accessibility-constraints)).
4200
4200
4201
-
An *indexer_body* may either consist of a statement body ([§15.7.1](classes.md#1571-general)) or an expression body ([§15.6.1](classes.md#1561-general)). In a statement body, *accessor_declarations*, which shall be enclosed in “`{`” and “`}`” tokens, declare the accessors ([§15.7.3](classes.md#1573-accessors)) of the indexer. The accessors specify the executable statements associated with reading and writing indexer elements.
4201
+
An *indexer_body* may either consist of a block body ([§15.7.1](classes.md#1571-general)) or an expression body ([§15.6.1](classes.md#1561-general)). In a block body, *accessor_declarations*, which shall be enclosed in “`{`” and “`}`” tokens, declare the accessors ([§15.7.3](classes.md#1573-accessors)) of the indexer. The accessors specify the executable statements associated with reading and writing indexer elements.
4202
4202
4203
-
In a *indexer_body* 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 read-only indexers where the result of the get accessor is given by a single expression.
4203
+
In a *indexer_body* an expression body consisting of “`=>`” followed by an expression `E` and a semicolon is exactly equivalent to the block body `{ get { return E; } }`, and can therefore only be used to specify read-only indexers where the result of the get accessor is given by a single expression.
4204
4204
4205
-
A *ref_indexer_body* may either consist of a statement body or an expression body. In a statement body a *get_accessor_declaration* declares the get accessor ([§15.7.3](classes.md#1573-accessors)) of the property. The accessor specifies the executable statements associated with reading the property.
4205
+
A *ref_indexer_body* may either consist of a block body or an expression body. In a block body a *get_accessor_declaration* declares the get accessor ([§15.7.3](classes.md#1573-accessors)) of the property. The accessor specifies the executable statements associated with reading the property.
4206
4206
4207
-
In a *ref_indexer_body* an expression body consisting of `=>` followed by `ref`, a *variable_reference*`V` and a semicolon is exactly equivalent to the statement body `{ get { return ref V; } }`.
4207
+
In a *ref_indexer_body* an expression body consisting of `=>` followed by `ref`, a *variable_reference*`V` and a semicolon is exactly equivalent to the block body `{ get { return ref V; } }`.
4208
4208
4209
4209
> *Note*: Even though the syntax for accessing an indexer element is the same as that for an array element, an indexer element is not classified as a variable. Thus, it is not possible to pass an indexer element as an `in`, `out`, or `ref` argument unless the indexer is ref-valued and therefore returns a reference ([§9.7](variables.md#97-reference-variables-and-returns)). *end note*
0 commit comments