draft proposal for Sum Types for D

Walter Bright newshound2 at digitalmars.com
Tue Nov 29 19:09:50 UTC 2022


On 11/29/2022 7:54 AM, deadalnix wrote:
> The first problem that needed to be solved is automated conversion between sum 
> types members. Think if you are trying to run this operation that exist on A but 
> not on B, and the sum value currently contains a B, then convert that B to an A 
> and then run the operation.

Why does the conversion need to be automated?

    S x;
    x.A = cast(typeof(S.A))x.B;


> The second one is that it ends up replacing builtin types in the codebase by 
> custom types, most notably dynamic arrays (which I'll call slices). Doing so de 
> facto breaks most of the codebase in ways that cannot be easily fixed, because 
> there is no way to have a builtin type that behave like a slice.

Can you be more specific about what doesn't work?



More information about the Digitalmars-d mailing list