draft proposal for Sum Types for D
Timon Gehr
timon.gehr at gmx.ch
Tue Nov 29 16:50:36 UTC 2022
On 11/29/22 16:42, Per Nordlöw wrote:
> On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:
>> Go ahead, Make My Day! Destroy!
>>
>> https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md
>
> DIP is missing
>
> - Canonicalization of `sumtype` members. Specifically:
> - Independence of order of members
> `sumtype S {T,U}` should be the same as `sumtype S {U,T}`.
> - Deduplication of members either as a compiler error or as a silent
> automatic removal of duplicate types.
That does not make much sense to me. You may want multiple distinct
cases with the same type.
> Moreover, what about
> `sumtype S {a T, b U}` vs `sumtype S {a U, b T}` and
> `sumtype S {a T, b U}` vs `sumtype S {b T, a U}`?
>
> For reference see how `mir.algebraic.Variant` canonicalizes template
> type parameters using the trait `TypeSet` at
> https://github.com/libmir/mir-core/blob/master/source/mir/algebraic.d#L447.
This does not seem to allow naming the cases, also, I think sumtype is
supposed to be closer to Algebraic than Variant.
More information about the Digitalmars-d
mailing list