Bottom type DIP 1017 and final rejection reasons?

Dennis dkorpel at gmail.com
Sun Mar 29 20:49:42 UTC 2020


On Sunday, 29 March 2020 at 18:18:49 UTC, aliak wrote:
> Was there any more on the details about it that is missing from 
> the DIP assessment part? [1]

Walter's DIP pitched the bottom-type as a more principled way to 
do a no-return attribute.
However, his bottom type was designed in such a constrained way 
that it basically could only be used as a no-return attribute, 
with all the added complexity of a new type without the benefits 
of a principled bottom type.

After the first round of community review, this critique wasn't 
addressed. The DIP remained basically unaltered, which spawned 
even more critique.

I think this post by Walter is very telling:

https://forum.dlang.org/post/q1obdu$6ap$1@digitalmars.com

Walter knows a bottom-type is a useful concept that is better 
than a no-return attribute, but had a hard time putting it into 
words for his DIP.

That's why I'm currently trying to reboot the DIP:

https://github.com/dlang/DIPs/pull/172

In the reboot I'm trying to focus on other uses than defining 
functions that do not return.

Some of the differences with the previous DIP are:
- the type name is `noreturn` instead of `TBottom`
- `typeof(null)` becomes `noreturn*` and `typeof([])` becomes 
`noreturn[]`.
- variables of type `noreturn` may be declared and used just like 
any other type
- throw-statements become expressions

This enables patterns that DIP1017 did not enable, such as:

```
import std;
void main() {
     [1].map!(x => x*2).writeln; // works
     [].map!(x => x*2).writeln; // error: can't instantiate map 
with void[]
     // if typeof([]) == noreturn[], the above will work too
}
```

```
void foo(int function() callback) {
     // ...
}

void main() {
     foo(() => throw new Exception());
     // works because `noreturn function()`
     // is covariant with `int function()`
}
```

Which hopefully shows that a bottom type is more than a no-return 
attribute.



More information about the Digitalmars-d mailing list