draft proposal for Sum Types for D
Andrey Zherikov
andrey.zherikov at gmail.com
Tue Nov 29 08:31:42 UTC 2022
On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:
This is very nice!
Few comments:
This looks like a typo making recursive grammar:
```d
SumTypeMembers:
SumTypeMembers // should it be SumTypeMember?
SumTypeMember `,`
SumTypeMember `,` SumTypeMembers
```
> `?x.allow ? x.allow : Xyzzy.busy`
Can this be shortened to `?x.allow : Xyzzy.busy`?
> But since a subtype with only enum members can be implemented
> as an enum, the compiler should do that rewrite. Similarly, a
> SumType with only one field declaration should be rewritten as
> a struct (and the tag can be omitted).
How will `?x.allow` be rewritten in these cases?
Other questions:
How will this work with Enum Type Inference?
Can this be used as an implementation of optional built-in type
in the future? (IMO this should be another DIP but would like to
get your thoughts)
More information about the Digitalmars-d
mailing list