Add design notes
This commit is contained in:
parent
95c5369c92
commit
ae60d8e4c8
|
@ -1,27 +1,28 @@
|
|||
# C# Language Design Notes for Mar 28, 2017
|
||||
|
||||
***Raw notes, yet to be cleaned up - read at your own peril***
|
||||
|
||||
## Agenda
|
||||
|
||||
Design remaining 7.1 features
|
||||
Design some remaining 7.1 features
|
||||
|
||||
1. Fix pattern matching restriction with generics
|
||||
2. Better best common type
|
||||
|
||||
|
||||
# permit match of expr of type T:base with derived
|
||||
# Fix pattern matching restriction with generics
|
||||
|
||||
Today `x as T` is allowed if
|
||||
|
||||
1. there is a reasonable relationship between the left and right type, or
|
||||
2. one of them is an open type
|
||||
|
||||
But for the `is` operator we don't have 2. That means that we can't always replace uses of `as` followed by null check with an `is` with a type pattern.
|
||||
But for the `is` operator we don't have the second. That means that we can't always replace uses of `as` followed by null check with an `is` with a type pattern.
|
||||
|
||||
Also, the restrictions are supposed to rule out only obviously useless cases, whereas some of these are demonstrably useful.
|
||||
|
||||
Let's allow it, look again if there are unexpected problems.
|
||||
|
||||
|
||||
# Better common type
|
||||
# Better best common type
|
||||
|
||||
Best common type should combine a value type with null literal to get a nullable value type.
|
||||
|
||||
|
@ -33,7 +34,7 @@ b1 ? 1 : (b2 ? null : (b3 ? 2 : default)); // default is 0
|
|||
b1 ? 1 : (b2 ? default : (b3 ? 2 : null)); // default is null
|
||||
```
|
||||
|
||||
This is weird, but fine.
|
||||
This is weird, but fine:
|
||||
|
||||
``` c#
|
||||
M(1, default, null); // int?
|
||||
|
@ -44,8 +45,3 @@ Next step is trying to spec it. It's a bit complicated.
|
|||
``` c#
|
||||
M(myShort, myNullableInt, null); Should continue to infer int? , not short?
|
||||
```
|
||||
# Lambda discards
|
||||
|
||||
# Mix
|
||||
|
||||
# Expr vars in initializers
|
|
@ -122,3 +122,11 @@ Discussion of default interface member implementations, based on [this guided to
|
|||
11. Static non-virtual members
|
||||
12. Accessibility levels
|
||||
13. Existing programs
|
||||
|
||||
## Mar 28, 2017
|
||||
[C# Language Design Notes for Mar 28, 2017](LDM-2017-03-28.md)
|
||||
|
||||
Design some remaining 7.1 features
|
||||
|
||||
1. Fix pattern matching restriction with generics
|
||||
2. Better best common type
|
||||
|
|
Loading…
Reference in a new issue