Tagged unions [Was: What's wrong with std.variant.Variant?]
Dukc
ajieskola at gmail.com
Mon Jun 15 21:48:19 UTC 2020
On Monday, 15 June 2020 at 16:30:17 UTC, Paul Backus wrote:
>
> SumType does not implement any member functions other than the
> ones listed in its documentation [1]: opAssign, opEquals,
> toString, and toHash.
>
> I am curious how you arrived at this misconception.
By cutting corners when doing research. Sorry.
> Is there a way I can improve SumType's documentation to make
> its behavior in this regard clearer?
It's not documentations fault. But if you want to supersede
Taggedalgebraic really hard, you can try convincing Mike to let
you write a project highlight in the D blog, to raise awareness
for thickskulls like me :D.
>
> In Rust's `enum` types you cannot access the tag directly.
Again bad research from my part. But it's something I want to do.
Why? `final switch` statements. I may want to `return` or `break`
directly from the switch, and in that case I can't use pattern
matching without extra thinking. Well, on D anyway. I don't know
about Rust.
More information about the Digitalmars-d
mailing list