draft proposal for Sum Types for D
Walter Bright
newshound2 at digitalmars.com
Wed Nov 30 04:17:23 UTC 2022
On 11/29/2022 12:37 PM, Jacob Carlborg wrote:
> ### ABI
Section added.
> ### Checking of the Tag
>
> The DIP mention there's a runtime check of the tag, but it doesn't specify what
> "runtime check" is.
Section added.
> This could potentially be extended to allow accessing the field without checking
> the tag, but require checking the tag before using the value, example:
Discussed in a reply to Timon.
> ### Breaking Changes
>
> Another breaking change, perhaps an edge case, but code that inspects all types
> and language constructs and performs different actions, i.e. a serialization
> library or something like `writeln`.
Added
> ### Switch Statement/Pattern Matching
>
> The DIP mentions that pattern matching is subject of another DIP. But I think
> it's reasonable that the switch statement should support sumtypes, in the same
> way as the if statement.
A match statement would make this redundant. In fact, I expect the match
statement to be lowered to a switch :-)
More information about the Digitalmars-d
mailing list