Sum Type by Struct
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sun Sep 22 15:40:10 UTC 2024
On 22/09/2024 10:43 PM, IchorDev wrote:
> On Thursday, 12 September 2024 at 11:28:56 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
>> In this proposal I propose a third sumtype design, one in which it is
>> based upon structs.
>
> One huge improvement would be to make the declaration syntax the same as
> that of structs as well. This would make it more consistent with the
> rest of the language, and allow conditional compilation statements, and
> potentially things like constructors and member functions. I suggest a
> `case` prefix like in Swift:
> ```d
> sumtype A{
> version(Nullable) case :None;
> case int, string text;
> }
> ```
I did have a similar syntax in the original version prior to this.
For the time being perhaps it would be better to leave it out.
I'll think about it.
More information about the dip.ideas
mailing list