February 20, 2020 Re: SumType in Phobos? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | 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. Fairly sad how common of a need it is: https://github.com/Geod24/minivariant#minivariant-simple-focused-variant-library |
February 20, 2020 Re: SumType in Phobos? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | 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 |
February 20, 2020 Re: SumType in Phobos? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Thursday, 20 February 2020 at 17:14:13 UTC, Paul Backus wrote:
> 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
I see now that the private function `as` should be qualified as @system.
Is this the mistake you are thinking about?
|
February 20, 2020 Re: SumType in Phobos? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Thursday, 20 February 2020 at 17:40:46 UTC, Per Nordlöw wrote:
> On Thursday, 20 February 2020 at 17:14:13 UTC, Paul Backus wrote:
>> 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
>
> I see now that the private function `as` should be qualified as @system.
>
> Is this the mistake you are thinking about?
In the `else` branch of the `static if` statement, if `T` has both a copy constructor and a destructor, the copy constructor is skipped but the destructor will still be called.
|
February 21, 2020 Re: SumType in Phobos? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Thursday, 20 February 2020 at 18:23:45 UTC, Paul Backus wrote:
> In the `else` branch of the `static if` statement, if `T` has both a copy constructor and a destructor, the copy constructor is skipped but the destructor will still be called.
I see. Thanks. I'll consider removing the template flag `memoryPacked`.
|
Copyright © 1999-2021 by the D Language Foundation