DIP 1017--Add Bottom Type--Final Review

Johan Engelen j at j.nl
Tue Jan 15 13:31:48 UTC 2019


On Tuesday, 15 January 2019 at 11:18:20 UTC, Simen Kjærås wrote:
> On Tuesday, 15 January 2019 at 10:59:40 UTC, Johan Engelen 
> wrote:
>> 4 - D already has a bottom type: `void`, why is a new type 
>> needed?
>
> Because `void` is not a bottom type - a bottom type has no 
> values, while void has exactly one, and is thus a unit type. 
> Proof: you can return from a void function (hence it has at 
> least one value), and no information is transmitted through a 
> void (hence it has at most one value).

Although I am not a mathematician, this argumentation feels 
broken. The argumentation of "a function returning bottom can 
never return" assumes mathematical functions (which must return a 
value), but in D a "function" is not necessarily a mathematical 
function. A function is a procedure, and can return no value, 
described by "void". For example, this is not allowed:
```
void foo();
void g() {
   auto f = foo(); // not allowed, foo does not return any value
}
```

Interestingly, the proposal defines `a || b()` to be OK when 
`b()` returns Tbottom, but does not change that it is not OK when 
`b()` returns `void`...

>> The declaration `extern(C) Tbottom exit();` won't mangle 
>> correctly
>
> False. C name mangling doesn't care about return types.

Indeed, thanks for the correction.

-Johan



More information about the Digitalmars-d mailing list