draft proposal for Sum Types for D

rikki cattermole rikki at cattermole.co.nz
Fri Dec 2 21:32:52 UTC 2022


On 03/12/2022 10:28 AM, deadalnix wrote:
> On Friday, 2 December 2022 at 16:43:45 UTC, Tejas wrote:
>> 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
> 
> It 100% will, because the next step in enlightenment here is to realize 
> that literal are also types with one value, and that the definitively 
> belong in there.

Yeah its better that we stick to ``sumtype Identifier = Arg1|Arg;`` 
syntax instead where binary operators don't have to be supported (except 
inside brackets).

Slightly unfortunate since that means we can't define it as part of a 
return type of a function or as a parameter.


More information about the Digitalmars-d mailing list