SumType in Phobos?
Paul Backus
snarwin at gmail.com
Thu Feb 20 17:14:13 UTC 2020
On Thursday, 20 February 2020 at 16:08:43 UTC, Per Nordlöw wrote:
> On Wednesday, 19 February 2020 at 06:52:04 UTC, Ernesto
> Castellotti wrote:
>> How about including SumType
>> (https://github.com/pbackus/sumtype) in Phobos?
>>
>> We know that std.variant.Algebraic has problems (nogc, nothrow
>> etc), SumType would be a wonderful solution to provide a tagged
>
> I also have an alternative to std.variant.Algebraic at
>
> https://github.com/nordlow/phobos-next/blob/master/src/nxt/variant.d
>
> which is @safe pure nothrow @nogc when possible and doesn't
> rely on TypeInfo. No explicit support for @BetterC.
This is missing what I consider the most important feature of
Algebraic and SumType, which is the ability to switch on the type
index with compile-time exhaustiveness checking (i.e., `visit` or
`match`).
The amount of @trusted code is also a red flag. I've already
found one mistake in it [1], which means there are probably at
least a couple more that I didn't catch.
[1]
https://github.com/nordlow/phobos-next/blob/master/src/nxt/variant.d#L226-L228
More information about the Digitalmars-d
mailing list