Sum Types - first draft

monkyyy crazymonkyyy at gmail.com
Tue Sep 10 20:26:32 UTC 2024


On Tuesday, 10 September 2024 at 16:20:55 UTC, Paul Backus wrote:
> On Tuesday, 10 September 2024 at 04:06:16 UTC, Walter Bright
>
>> * std.sumtype cannot optimize the tag out of existence, for 
>> example, when having:
>>
>>       enum Option { None, int* Ptr }
>
> A built-in sum type would not be able to do this either, 
> because in D, every possible sequence of 4 bytes is a 
> potentially-valid int* value.

Isnt the `int*=cast()0` labled as invalid by the type theory 
inherited from c?

You shouldnt do such a thing if you were designing from scratch 
but I think walters correct here, you *could* even if you shouldnt

Likewise you could collapse nullable!float into a wrapper of 
float and use nan as a invalid state; you shouldnt and nan should 
be destroyed; but you could.


More information about the dip.development mailing list