draft proposal for Sum Types for D

Max Samukha maxsamukha at gmail.com
Fri Dec 2 06:19:42 UTC 2022


On Friday, 2 December 2022 at 05:23:53 UTC, Walter Bright wrote:
> sumtype Nullable { Null = null, int* Ptr }
>
> where the `= null` triggers the special case, as it is not an 
> integer.
>

On Friday, 2 December 2022 at 05:23:53 UTC, Walter Bright wrote:
>
> I know, but the syntax is a bit unappealing. How about:
>
> sumtype Nullable { Null = null, int* Ptr }
>
> where the `= null` triggers the special case, as it is not an 
> integer.

Singling out pointers still feels like a hack. What about all the 
other types that are already sums with an "invalid" value?

sumtype Error
{
     error = 0, int value
     // error = char.init, char value
     // error = T.invalid, T value
}



More information about the Digitalmars-d mailing list