Updated records in proposal "discriminated-unions" (#4014)
Changed "data class" in examples to "record" and some other adjustments to conform more with records. Also swapped position of "partial" and "abstract" because apparently the compiler only likes it the other way. To get the examples to compile the classes that contain the records ("Shape", "Binary" and "Expr") should also be changed to record but I left that out for now.
This commit is contained in:
Родитель
843230d5c0
Коммит
f6a4820041
|
@ -84,10 +84,10 @@ enum class Shape
|
|||
the `enum class` declaration has semantics equivalent to the following declaration
|
||||
|
||||
```C#
|
||||
partial abstract class Shape
|
||||
abstract partial class Shape
|
||||
{
|
||||
public data class Rectangle(float Width, float Length) : Shape,
|
||||
public data class Circle(float Radius) : Shape
|
||||
public record Rectangle(float Width, float Length) : Shape;
|
||||
public record Circle(float Radius) : Shape;
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -117,12 +117,12 @@ the nested enum class defines a nested root type, and everything below the neste
|
|||
class is a subtype of the nested root type, instead of the top-level root type.
|
||||
|
||||
```C#
|
||||
partial abstract class Expr
|
||||
abstract partial class Expr
|
||||
{
|
||||
partial abstract class Binary : Expr
|
||||
abstract partial class Binary : Expr
|
||||
{
|
||||
public data class Addition(Expr left, Expr right) : Binary,
|
||||
public data class Multiplication(Expr left, Expr right) : Binary
|
||||
public record Addition(Expr left, Expr right) : Binary;
|
||||
public record Multiplication(Expr left, Expr right) : Binary;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -188,4 +188,4 @@ check.
|
|||
- [ ] Should there be a way to make `enum class`es not be considered complete in the switch
|
||||
expression? Prefix with `virtual`?
|
||||
|
||||
- [ ] What modifiers should be permitted on `enum class`?
|
||||
- [ ] What modifiers should be permitted on `enum class`?
|
||||
|
|
Загрузка…
Ссылка в новой задаче