Skip to content

Commit e51b80c

Browse files
RexJaeschkeBillWagner
authored andcommitted
reorg record-related text
1 parent 7807923 commit e51b80c

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

standard/classes.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5663,6 +5663,67 @@ An enumerable object provides an implementation of the `GetEnumerator` methods o
56635663

56645664
An asynchronous enumerable object provides an implementation of the `GetAsyncEnumerator` method of the `IAsyncEnumerable<T>` interface. This method returns an available asynchronous enumerator object. The enumerator object is initialized with the argument values and instance value saved when the enumerable object was initialized, including the optional cancellation token, but otherwise the enumerator object functions as described in [§15.15.5](classes.md#15155-enumerator-objects). An asynchronous iterator method can mark one parameter as the cancellation token using `System.Runtime.CompilerServices.EnumeratorCancellationAttribute` ([§23.5.8](attributes.md#2358-the-enumeratorcancellation-attribute)). An implementation shall provide a mechanism to combine cancellation tokens such that an asynchronous iterator is canceled when either cancellation token (the argument to `GetAsyncEnumerator` or the argument attributed with the attribute `System.Runtime.CompilerServices.EnumeratorCancellationAttribute`) requests cancellation.
56655665

5666+
## §rec-class Record classes
5667+
5668+
### §rec-class-general General
5669+
5670+
A record class is a specialized reference type that is optimized for storing data rather than behavior. It provides built-in functionality that would normally require significant “boilerplate” code in a non-record class, such as value-based equality and easy immutability.
5671+
5672+
```ANTLR
5673+
record_class_declaration
5674+
: attributes? class_modifier* 'partial'? 'record' identifier
5675+
type_parameter_list? delimited_parameter_list? class_base?
5676+
type_parameter_constraints_clause* record_class_body
5677+
;
5678+
```
5679+
5680+
A *record_class_declaration* consists of an optional set of *attributes* ([§21](attributes.md#21-attributes)), followed by an optional set of *class_modifier*s ([§14.2.2](classes.md#1422-class-modifiers)), followed by an optional `partial` modifier ([§14.2.7](classes.md#1427-partial-declarations)), followed by the keyword `record` and an *identifier* that names the class, followed by an optional *type_parameter_list* ([§14.2.3](classes.md#1423-type-parameters)), followed by an optional *delimited_parameter_list* ([§15.6.2.1]( classes.md#15621-general)), followed by an optional *class_base* specification ([§14.2.4](classes.md#1424-class-base-specification)), followed by an optional set of *type_parameter_constraints_clause*s ([§14.2.5](classes.md#1425-type-parameter-constraints)), followed by a *record_class_body* (§rec-class-record-class-body).
5681+
5682+
*class_modifier* shall not be `static`.
5683+
5684+
A *record_class_declaration* having a *delimited_parameter_list* declares a ***positional record class***.
5685+
5686+
At most only one partial type declaration of a partial record class may provide a *delimited_parameter_list*.
5687+
5688+
Parameters in * delimited_parameter_list* shall not have `ref`, `out` or `this` modifiers; however, `in` and `params` modifiers are permitted.
5689+
5690+
### §rec-class-class-base-specification Class base specification
5691+
5692+
```ANTLR
5693+
base_argument_list
5694+
: '(' argument_list? ')'
5695+
;
5696+
```
5697+
5698+
### §rec-class-record-class-body Record class body
5699+
5700+
The *record_class_body* of a record class defines the members of that class.
5701+
5702+
```ANTLR
5703+
record_class_body
5704+
: class_body ';'?
5705+
| ';'
5706+
;
5707+
```
5708+
5709+
The *record_class_body*s `{}`, `{};`, and `;` are equivalent. They all indicate that the only members are those synthesized by the compiler (§synth-members).
5710+
5711+
### §rec-class-class-members Class members
5712+
5713+
For a record class, the member set also includes the synthesized members generated by the compiler (§synth-members).
5714+
5715+
It is an error for a member of a record class to be named `Clone`.
5716+
5717+
It is an error for an instance field of a record class to have an unsafe type.
5718+
5719+
### §rec-class-instance-constructors Instance constructors
5720+
5721+
A positional record class (§rec-class-general) has a synthesized primary constructor; see §rec-class-pos-mem-pricon for more information.
5722+
5723+
5724+
5725+
5726+
56665727
## §synth-members Synthesized record class members
56675728

56685729
### §synth-members-general General

0 commit comments

Comments
 (0)