@kcvinu @miran, yes I'm using devel.

I also prefer tagged union (also called sum types) in general to avoid the 
pointer indirection.

Just be aware that with the second solution (inheritance/polymorphism) any user 
of your library can extend your base type with its own and reuse the methods 
you define while with the first solution (object variant/tagged union/sum type) 
adding a new subtype means modifying all proc using this type.

The following blog post "[Sum Types Are 
Coming](https://chadaustin.me/2015/07/sum-types/)" summarizes that very well:

> With sum types, it’s easy to add uses but hard to add cases. > With 
> interfaces, it’s easy to add cases but hard to add uses.

Uses are new procs: it's easy to add new ones with sum types "proc foo = case 
...", while with interfaces you need to update the base interface and add 
methods for each derived classes.

Cases are new subtypes: just derive from the base type in interfaces, but with 
sum types you need to update your case statement in all the procs.

Reply via email to