Blog Post: Beating std::visit Without Really Trying

Seb seb at wilzba.ch
Sun Oct 6 08:27:35 UTC 2019


On Sunday, 6 October 2019 at 07:16:03 UTC, Joseph Rushton 
Wakeling wrote:
> On Sunday, 6 October 2019 at 03:47:25 UTC, Seb wrote:
>> My earlier post tried to point out that SumType is an 
>> excellent candidate for v2.
>
> Sorry, Seb, but I don't get this. There's no reason to wait for 
> a v2 to introduce a new SumType symbol that outperforms the old 
> Variant (assuming it's not possible to just rewrite the latter 
> implementation under the hood without changing behaviour).

Well, my guess it will be similar to that one time when `Option` 
(https://github.com/dlang/phobos/pull/3915) was rejected because 
it was only slightly better than `only` or the other time when it 
was attempted to improve `Nullable` (e.g. 
https://github.com/dlang/phobos/pull/6253)?
Alternatively, there is also the route pioneered by 
std.typecons.wrap whose improvements are - after more than four 
years - still stuck in std.experimental.wrap 
(https://github.com/dlang/phobos/pull/2945, 
https://dlang.org/phobos/std_experimental_typecons.html#.wrap).


> On the contrary, the best way to do a v2 is likely to be that 
> all or most of the stuff we want in it is already there and has 
> been battle tested in the wild.

A standard library is _not_ supposed to be a place where actual 
battle-testing happens. It's where things move when they have 
been tested and no longer change. This "readiness" condition is 
one of the reasons why only a single function has been added to 
Phobos in 2019 so far.

Please don't misunderstand me: I would love to see SumType in 
Phobos. There are tons of other great modules that would make a 
great base as well, e.g. 
http://rumbu13.github.io/decimal/doc/decimal.html, 
https://code.dlang.org/packages/optional, or 
https://github.com/dlang-community/std_data_json etc.
I plainly doubt that we will ever see them in the current Phobos.


More information about the Digitalmars-d-announce mailing list