Enumerated Unions (sum types)

Paul Backus snarwin at gmail.com
Thu Sep 12 09:48:13 UTC 2024


On Thursday, 12 September 2024 at 08:55:01 UTC, cookiewitch wrote:
> On Thursday, 12 September 2024 at 02:42:17 UTC, Paul Backus 
> wrote:
>> https://gist.github.com/pbackus/28e7f5668219ce83467c83c347ec7202
>>
>> This DIP proposes a conservative design for sum types that 
>> aims to be consistent with existing D syntax and semantics. It 
>> does not discuss pattern matching.
>
> Does the `__tag` property have to be prefixed with a double 
> underscore? Properties for any existing types don't appear to 
> use underscores. Even if different in semantics from other 
> fields, I don't think it needs an exception.

The point of the double underscore is to avoid name collision 
with a user-defined field or method.

Ideally, most users would use pattern matching, and never have to 
check `__tag` directly.


More information about the dip.ideas mailing list