Skip to content

Commit 00cba6e

Browse files
BillWagnerjskeet
andauthored
Wordsmithing return by ref (#1006)
* wordsmiting on return-by-ref Fixes #805 Clarify that return-by-ref expressions are evaluated the same as return-by-value expressions. The distinction is that for return-by-ref, the result must be a variable reference. * bonus typo fix * Update standard/statements.md Co-authored-by: Jon Skeet <[email protected]> --------- Co-authored-by: Jon Skeet <[email protected]>
1 parent dc288d9 commit 00cba6e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

standard/statements.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ Implicitly typed declarations contain the contextual keyword ([§6.4.4](lexical-
313313
- If there is no type named `var` in scope and the input matches *implicitly_typed_local_variable_declaration* then it is chosen;
314314
- Otherwise if a type named `var` is in scope then *implicitly_typed_local_variable_declaration* is not considered as a possible match.
315315

316-
Within a *local_variable_declaration* each variable is introduced by a ***declarator***, which is one of *implicitly_typed_local_variable_declarator*, *explicitly_typed_local_variable_declarator* or *ref_local_variable_declarator* for impicitly typed, explicitly typed and ref local variables respectively. The declarator defines the name (*identifier*) and initial value, if any, of the introduced variable.
316+
Within a *local_variable_declaration* each variable is introduced by a ***declarator***, which is one of *implicitly_typed_local_variable_declarator*, *explicitly_typed_local_variable_declarator* or *ref_local_variable_declarator* for implicitly typed, explicitly typed and ref local variables respectively. The declarator defines the name (*identifier*) and initial value, if any, of the introduced variable.
317317

318318
If there are multiple declarators in a declaration then they are processed, including any initializing expressions, in order left to right ([§9.4.4.5](variables.md#9445-declaration-statements)).
319319

@@ -1523,7 +1523,7 @@ It is a compile-time error for a `return` statement to appear in a `finally` blo
15231523
15241524
A `return` statement is executed as follows:
15251525
1526-
- For a return-by-value, *expression* is evaluated and its value is converted to the effective return type of the containing function by an implicit conversion. The result of the conversion becomes the result value produced by the function. For a return-by-ref, a reference to the *variable_reference* designated by *expression* becomes the result produced by the function. That result is a variable. If the enclosing method’s return-by-ref includes `readonly`, the resulting variable is read-only.
1526+
- For a return-by-value, *expression* is evaluated and its value is converted to the effective return type of the containing function by an implicit conversion. The result of the conversion becomes the result value produced by the function. For a return-by-ref, the *expression* is evaluated, and the result shall be classified as a variable. If the enclosing method’s return-by-ref includes `readonly`, the resulting variable is read-only.
15271527
- If the `return` statement is enclosed by one or more `try` or `catch` blocks with associated `finally` blocks, control is initially transferred to the `finally` block of the innermost `try` statement. When and if control reaches the end point of a `finally` block, control is transferred to the `finally` block of the next enclosing `try` statement. This process is repeated until the `finally` blocks of all enclosing `try` statements have been executed.
15281528
- If the containing function is not an async function, control is returned to the caller of the containing function along with the result value, if any.
15291529
- If the containing function is an async function, control is returned to the current caller, and the result value, if any, is recorded in the return task as described in ([§15.15.3](classes.md#15153-evaluation-of-a-task-returning-async-function)).

0 commit comments

Comments
 (0)