Shameless autopromotion : type safe tagged union in D

deadalnix deadalnix at gmail.com
Thu May 16 20:48:06 PDT 2013


On Thursday, 16 May 2013 at 18:30:22 UTC, Nick Sabalausky wrote:
> On Fri, 10 May 2013 14:32:48 +0200
> "deadalnix" <deadalnix at gmail.com> wrote:
>
>> http://www.deadalnix.me/2013/05/10/type-safe-tagged-union-in-d-programming-language/
>> 
>> A trick that I used to use more and more, so I ended up 
>> creating a generic solution and wrote an article about it.
>
> Nice article, but is there any particular problem with
> std.variant.Algebraic?

Yes, : it is user responsibility to poll types and act 
accordingly. In the presented code, this is the responsibility of 
the data structure.

For instance, if I add a new type, with Algebraic, I'll have to 
go over all my code base to patch every use. If I don't, my code 
become silently incorrect. With the presented solution, I'll get 
a compile time error.


More information about the Digitalmars-d-announce mailing list