-
Notifications
You must be signed in to change notification settings - Fork 1k
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 lambda-improvements.md to match language design decisions #5388
Conversation
```csharp | ||
var fs = new[] { (string s) => s.Length; (string s) => int.Parse(s) } // Func<string, int>[] | ||
``` | ||
|
||
### `var` | ||
Lambda expressions and method groups with natural types can be used as initializers in `var` declarations. | ||
Anonymous functions and method groups with inferred types can be used as initializers in `var` declarations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -210,52 +245,47 @@ var f7 = "".F1; // System.Action | |||
var f8 = F2; // System.Action<string> | |||
``` | |||
|
|||
The type of an anonymous function or method group is not inferred for implicitly-typed discards. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider: "Function types are not used in assignments to discards" #Resolved
@@ -276,6 +306,19 @@ lambda_parameter | |||
; | |||
``` | |||
|
|||
## Open issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't those open issues been resolved already?
Should the _function_type_ be available from the compiler API, in addition to the resulting delegate type? | ||
|
||
Currently, the inferred delegate type uses `System.Action<>` or `System.Func<>` when parameter and return types are valid type arguments _and_ there are no more than 16 parameters, and if the expected `Action<>` or `Func<>` type is missing, an error is reported. Instead, should the compiler use `System.Action<>` or `System.Func<>` regardless of arity? And if the expected type is missing, synthesize a delegate type otherwise? | ||
|
||
## Design meetings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this list to the championed issue (easier to update), or only keeping it here and updating it with latest links. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with review pass (iteration 10)
Various updates to proposals/csharp-10.0/lambda-improvements.md to match language design decisions and C#10 implementation:
var
cannot be used as an explicit return type (see 2021-06-02)object
(see 2021-08-23)