draft proposal for Sum Types for D
Dark Hole
dark.hole1 at yandex.ru
Tue Nov 29 09:28:02 UTC 2022
On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:
> Go ahead, Make My Day! Destroy!
>
> https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md
I don't understand `read` code:
```d
Xyzzy x = Xyzzy.busy;
Xyzzy y = x.busy; // ok
y = x.allow; // runtime error
y = ?x.allow ? x.allow : Xyzzy.busy;
x = Xyzzy.allow(3);
y = x.allow; // ok
```
As I thought the type of `x.allow` is `int` and `x.busy` is
(probably) `void`. But then we assigning them to `y` which type
is `Xyzzy`. How should it work? Implicit cast? Or it should be
read like `y = ?x.allow ? x : assert(0)`?
Also what will be in `nothrow` code? Can we access members of
sumtype?
More information about the Digitalmars-d
mailing list