The NaN of types (in D)

Stefan Koch uplink.coder at googlemail.com
Sun Oct 11 15:23:45 UTC 2020


On Sunday, 11 October 2020 at 15:19:17 UTC, Paul Backus wrote:
> On Sunday, 11 October 2020 at 12:18:59 UTC, Stefan Koch wrote:
>> So we need a type that behaves just like Terror (i.e. is not 
>> considered a type by the is expression) but is not an error.
>>
>> This type is the empty type (Ø).
>> It is emptier than void and on the same level as bottom (⊥).
>> But Ø cannot be ⊥, because ⊥ can be a valid return type of a 
>> function.
>> (At least once we have the ⊥ type)
>>
>> Ø not being a valid type as far as the is expression is 
>> concerned.
>> (is(Ø) yields false)
>> Also means that is(Ø == Ø) also yields false.
>
> To me, this sounds more like an empty Optional!__type or a null 
> __type* than a NaN. Maybe it would be better to leave __type as 
> the non-nullable version, and use something like __type* to 
> represent a type that may be absent.

__type need an init value otherwise phobos breaks all over the 
place.
and it's much nicer if that value is not part of the domain.
you can compare it 0.
You can do calculations without 0 but it gets very complicated 
very fast.
The empty type is awesome! I love it!
It allows me to simplify proofs so much.


More information about the Digitalmars-d mailing list