draft proposal for Sum Types for D
rikki cattermole
rikki at cattermole.co.nz
Tue Nov 29 15:26:07 UTC 2022
Something else I want to talk a bit more on.
Sumtypes are not distinct in the type system. They are like alias, its
just a collection of values/behavior that is given a name.
You would need to use features like templates, conditional compilation,
UDA's ext. to make it distinct and even then they should be implicitly
convertible as long as its a superset or equal in members.
This extends over to the AST implementation stuff, it means there would
need to be a global table containing the actual instances and when you
instantiate a templated sumtype the instance would effectively be just
an alias into an entry in that table.
Like None, the non-distinctiveness of sumtypes is fundamental in the
type theory and comes from set theory. So its important that we get this
right, because it has a lot of flow on effects.
More information about the Digitalmars-d
mailing list