Skip to content

Specify temporary for this as an input parameter #927

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

Merged
merged 4 commits into from
Sep 20, 2023
Merged
Changes from all 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
7 changes: 6 additions & 1 deletion standard/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,12 @@ The run-time processing of a function member invocation consists of the followin
- `M` is invoked.
- Otherwise, if the type of `E` is a value-type `V`, and `M` is declared or overridden in `V`:
- `E` is evaluated. If this evaluation causes an exception, then no further steps are executed. For an instance constructor, this evaluation consists of allocating storage (typically from an execution stack) for the new object. In this case `E` is classified as a variable.
- If `E` is not classified as a variable, then a temporary local variable of `E`’s type is created and the value of `E` is assigned to that variable. `E` is then reclassified as a reference to that temporary local variable. The temporary variable is accessible as `this` within `M`, but not in any other way. Thus, only when `E` is a true variable is it possible for the caller to observe the changes that `M` makes to `this`.
- If `E` is not classified as a variable, or if `V` is not a readonly struct type (§16.2.2), and `E` is one of:
- an input parameter (§15.6.2.3), or
- a `readonly` field (§15.5.3), or
- a `readonly` reference variable or return (§9.7),

then a temporary local variable of `E`’s type is created and the value of `E` is assigned to that variable. `E` is then reclassified as a reference to that temporary local variable. The temporary variable is accessible as `this` within `M`, but not in any other way. Thus, only when `E` can be written is it possible for the caller to observe the changes that `M` makes to `this`.
- The argument list is evaluated as described in [§12.6.2](expressions.md#1262-argument-lists).
- `M` is invoked. The variable referenced by `E` becomes the variable referenced by `this`.
- Otherwise:
Expand Down