- Proposed
- Prototype: None
- Implementation: None
- Specification: See below
We extend the features introduced in C# 7 to permit expressions containing expression variables (out variable declarations and declaration patterns) in field initializers, property initializers, ctor-initializers, and query clauses.
This completes a couple of the rough edges left in the C# language due to lack of time.
We remove the restriction preventing the declaration of expression variables (out variable declarations and declaration patterns) in a ctor-initializer. Such a declared variable is in scope throughout the body of the constructor.
We remove the restriction preventing the declaration of expression variables (out variable declarations and declaration patterns) in a field or property initializer. Such a declared variable is in scope throughout the initializing expression.
We remove the restriction preventing the declaration of expression variables (out variable declarations and declaration patterns) in a query expression clause that is translated into the body of a lambda. Such a declared variable is in scope throughout that expression of the query clause.
None.
The appropriate scope for expression variables declared in these contexts is not obvious, and deserves further LDM discussion.
- What is the appropriate scope for these variables?
None.