Skip to content
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

Update records-wip.md #3353

Merged
merged 8 commits into from
Apr 30, 2020
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions proposals/records-wip.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ For a record struct or a record class:

* A public get-only auto-property is created. Its value is initialized during construction with the value of the corresponding primary constructor parameter. Each "matching" inherited abstract property's get accessor is overridden.

* This property is also `initonly`, meaning the backing field can be modified in the [with](#With) expression below, if the corresponding `get` accessor is accessible
333fred marked this conversation as resolved.
Show resolved Hide resolved

### Equality members

Record types produce synthesized implementations for the following methods:
Expand Down Expand Up @@ -89,13 +91,16 @@ A `with` expression allows for "non-destructive mutation", designed to
produce a copy of the receiver expression with modifications to properties
listed in the `anonymous_object_initializer`.

A valid `with` expression has a receiver with a non-void type. The receiver type must contain an accessible parameterless instance method called `Clone` whose return type must be the type of the receiver express type, or a base type thereof.
agocke marked this conversation as resolved.
Show resolved Hide resolved
A valid `with` expression has a receiver with a non-void type. The receiver type must contain an accessible
parameterless instance method called `Clone` whose return type must be the receiver type, or a base type thereof.

On the right hand side of the `with` expression is an `anonymous_object_initializer` with a
sequence of assignments with a compiler-generated record property of the receiver on the left-hand side of the
assignment, and an arbitrary expression on the right-hand side which is implicitly convertible to the type
of the left-hand side.
sequence of assignments, each with an `initonly` property (see [Properties](#Properties)) of the `Clone`
agocke marked this conversation as resolved.
Show resolved Hide resolved
return type on the left-hand side of the assignment, and an arbitrary expression on the right-hand side which is
implicitly convertible to the type of the property.

The evaluation of a `with` expression calls the `Clone` method exactly once,
and then sets the backing field of each `initonly` property in the argument list to
agocke marked this conversation as resolved.
Show resolved Hide resolved
the value of its corresponding expression, in lexical order, using the result of the `Clone` method
invocation as the receiver.

The evaluation of a `with` expression is equivalent to calling the `Clone` method exactly once,
and then setting the backing field of each record property in the argument list to its corresponding
expression, in lexical order, using the result of the `Clone` method as the receiver.