DIP 1017--Add Bottom Type--Final Review

Tobias Müller troplin at bluewin.ch
Tue Jan 22 06:29:41 UTC 2019


H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
> On Thu, Jan 17, 2019 at 09:43:52PM +0000, Jonathan Marler via Digitalmars-d wrote:
>[...]
>> That's conceptually the same thing.  Saying that TBottom* is "always
>> equal to null" is the same as saying it's a Unit Type, which is the
>> same as saying that it contains no information so the storage needed
>> is 0 (same as void).
> 
> I'm not so sure about that.  A true Unit type conveys no information,
> yet TBottom* conveys at least this information: that it's a pointer, and
> that the pointer cannot be dereferenced.  A true Unit type would be the
> return type of a void function; would you equate TBottom* with the
> return type of a void function?  That would be very strange indeed.

A unit type carrying no value means that the *dynamic value at runtime*
carries no information that is not already known from the type itself.

Take 'bool' as an example. It carries only one bit of dynami information,
yet from the type itself you also know that it's no 'int' or pointer type
which is definitely more than one bit of information. But it's the dynamic
information that counts.

If you have a variable (or return value) of type 'TBottom*' you already
know from the type that the value will be 'null'. In other words there is
no need to use any storage for that value.

Tobi



More information about the Digitalmars-d mailing list