From 460f29a006be3745180ce3c79c88e68b8c49ff92 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Mon, 27 Mar 2023 11:36:48 -0400 Subject: [PATCH] updates based on feedback. --- standard/classes.md | 14 ++++++++------ standard/conversions.md | 5 ++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/standard/classes.md b/standard/classes.md index 28cfd0df3..71f5359a1 100644 --- a/standard/classes.md +++ b/standard/classes.md @@ -5200,7 +5200,13 @@ The exact definition of the task types is implementation-defined, but from the l > > *end example* -A task builder type is a class or struct type that corresponds to a specific task type. A task builder type can have at most one type parameter and cannot be nested in a generic type. A task builder type shall have the following accessible members (for non-generic task builder types, `SetResult` has no parameters): +A task builder type is a class or struct type that corresponds to a specific task type (§task-builder-pattern). + +An async function has the ability to suspend evaluation by means of await expressions ([§11.8.8](expressions.md#1188-await-expressions)) in its body. Evaluation may later be resumed at the point of the suspending await expression by means of a ***resumption delegate***. The resumption delegate is of type `System.Action`, and when it is invoked, evaluation of the async function invocation will resume from the await expression where it left off. The ***current caller*** of an async function invocation is the original caller if the function invocation has never been suspended or the most recent caller of the resumption delegate otherwise. + +### §task-builder-pattern Task-type builder pattern + +A task builder type can have at most one type parameter and cannot be nested in a generic type. A task builder type shall have the following accessible members (for non-generic task builder types, `SetResult` has no parameters): ```csharp class «TaskBuilderType» @@ -5223,11 +5229,7 @@ class «TaskBuilderType» } ``` -An async function has the ability to suspend evaluation by means of await expressions ([§11.8.8](expressions.md#1188-await-expressions)) in its body. Evaluation may later be resumed at the point of the suspending await expression by means of a ***resumption delegate***. The resumption delegate is of type `System.Action`, and when it is invoked, evaluation of the async function invocation will resume from the await expression where it left off. The ***current caller*** of an async function invocation is the original caller if the function invocation has never been suspended or the most recent caller of the resumption delegate otherwise. - -### §task-builder-pattern Task-type builder pattern - -The compiler generates code that uses the «TaskBuilderType» to implement the semantics of suspending and resuming the evaluation of the async function. The uses the «TaskBuilderType» as follows: +The compiler generates code that uses the «TaskBuilderType» to implement the semantics of suspending and resuming the evaluation of the async function. The compiler uses the «TaskBuilderType» as follows: - `«TaskBuilderType».Create()` is invoked to create an instance of the «TaskBuilderType», named `builder` in this list. - `builder.Start(ref stateMachine)` is invoked to associate the builder with a compiler-generated state machine instance, `stateMachine`. diff --git a/standard/conversions.md b/standard/conversions.md index 99eb84d07..51b607e03 100644 --- a/standard/conversions.md +++ b/standard/conversions.md @@ -743,10 +743,9 @@ Specifically, an anonymous function `F` is compatible with a delegate type `D` - If `F` does not contain an *anonymous_function_signature*, then `D` may have zero or more parameters of any type, as long as no parameter of `D` has the out parameter modifier. - If `F` has an explicitly typed parameter list, each parameter in `D` has the same type and modifiers as the corresponding parameter in `F`. - If `F` has an implicitly typed parameter list, `D` has no ref or out parameters. - - If the body of `F` is an expression, and *either* `D` has a void return type *or* `F` is async and `D` has the return type `«TaskType»` (§14.15.1](classes.md#14151-general)), then when each parameter of `F` is given the type of the corresponding parameter in `D`, the body of `F` is a valid expression (w.r.t [§11](expressions.md#11-expressions)) that would be permitted as a *statement_expression* ([§12.7](statements.md#127-expression-statements)). -- If the body of `F` is a block, and *either* `D` has a void return type *or* `F` is async and `D` has the return type `«TaskType»`, then when each parameter of `F` is given the type of the corresponding parameter in `D`, the body of `F` is a valid block (w.r.t [§12.3](statements.md#123-blocks)) in which no `return` statement specifies an expression. -- If the body of `F` is an expression, and *either* `F` is non-async and `D` has a non-`void` return type `T`, *or* `F` is async and `D` has a return type `«TaskType»` ([§14.15.1](classes.md#14151-general)), then when each parameter of `F` is given the type of the corresponding parameter in `D`, the body of `F` is a valid expression (w.r.t [§11](expressions.md#11-expressions)) that is implicitly convertible to `T`. +- If the body of `F` is a block, and *either* `D` has a void return type *or* `F` is async and `D` has a `«TaskType»` return type , then when each parameter of `F` is given the type of the corresponding parameter in `D`, the body of `F` is a valid block (w.r.t [§12.3](statements.md#123-blocks)) in which no `return` statement specifies an expression. +- If the body of `F` is an expression, and *either* `F` is non-async and `D` has a non-`void` return type `T`, *or* `F` is async and `D` has a `«TaskType»` return type ([§14.15.1](classes.md#14151-general)), then when each parameter of `F` is given the type of the corresponding parameter in `D`, the body of `F` is a valid expression (w.r.t [§11](expressions.md#11-expressions)) that is implicitly convertible to `T`. - If the body of `F` is a block, and *either* `F` is non-async and `D` has a non-void return type `T`, *or* `F` is async and `D` has a return type `«TaskType»`, then when each parameter of `F` is given the type of the corresponding parameter in `D`, the body of `F` is a valid statement block (w.r.t [§12.3](statements.md#123-blocks)) with a non-reachable end point in which each return statement specifies an expression that is implicitly convertible to `T`. > *Example*: The following examples illustrate these rules: