draft proposal for Sum Types for D

rikki cattermole rikki at cattermole.co.nz
Tue Nov 29 16:39:03 UTC 2022


On 30/11/2022 5:18 AM, oconnor0 wrote:
> Can you explain this a little more? Sumtype constructors/tags don't 
> necessarily have to be shared across all possible sumtypes. For example, 
> Ocaml has polymorphic variants that do not tie tags to types 
> (https://v2.ocaml.org/manual/polyvariant.html) and variants that do tie 
> tags to types 
> (https://v2.ocaml.org/manual/coreexamples.html#s:tut-recvariants).

 From what I'm seeing its not about the tag, its about how the members 
get defined and what limit are placed upon the inferation and expansion 
of sumtypes in usage. We don't have that sort of type system where this 
is really possible. Other type systems such as the one ML is based on 
(there are multiple different conflicting branches in the type thoery 
literature) can utilize such behavior.


More information about the Digitalmars-d mailing list