draft proposal for Sum Types for D
Tejas
notrealemail at gmail.com
Fri Dec 2 16:43:45 UTC 2022
On Friday, 2 December 2022 at 05:23:53 UTC, Walter Bright wrote:
> On 11/29/2022 6:45 AM, Timon Gehr wrote:
>> [...]
>
> In defense, I would add that Rust appears to just the same
> thing. Except that Rust pointers can't be null. I do understand
> the notion that a quirk may cause problems.
>
>
>> [...]
>
> I know, but the syntax is a bit unappealing. How about:
>
> sumtype Nullable { Null = null, int* Ptr }
>
> where the `= null` triggers the special case, as it is not an
> integer.
>
>> [...]
>
> What you get is a better error message than seg fault.
>
>> [...]
>
> The user isn't going to want to do that if he knows the tag is
> correct. Array buffer overflow checks are also hidden from the
> user.
Is it possible to make the syntax `int|float|char` style? We
could parameterize it as `alias type(T) = int|float|customType!T;`
Or will it mess with bitwise expressions too much? It _kinda_
shouldn't since all the operands in bitwise or are variables, but
here they will _all_ be types
More information about the Digitalmars-d
mailing list