DIP 1017--Add Bottom Type--Final Review
Jonathan Marler
johnnymarler at gmail.com
Tue Jan 15 16:01:13 UTC 2019
On Tuesday, 15 January 2019 at 08:59:07 UTC, Mike Parker wrote:
> DIP 1017, "Add Bottom Type", is now ready for Final Review.
> This is the last chance for community feedback before the DIP
> is handed off to Walter and Andrei for the Formal Assessment.
> Please read the procedures document for details on what is
> expected in this review stage:
>
> https://github.com/dlang/DIPs/blob/master/PROCEDURE.md#final-review
>
> The current revision of the DIP for this review is located here:
>
> https://github.com/dlang/DIPs/blob/4716033a8cbc2ee024bfad8942b2ff6b63521f63/DIPs/DIP1017.md
>
> In it you'll find a link to and summary of the previous review
> round. This round of review will continue until 11:59 pm ET on
> January 30 unless I call it off before then.
>
> Thanks in advance for your participation.
I'd like to point out that this proposal is introducing 2 new
semantic features that are related but actually orthogonal.
1. Allow a functions to be marked as "no return"
2. Introduce a "bottom" type defined as typeof(assert(0)). Any
function that returns this type will be marked as "no return".
Other reviewers have asked for why using a "bottom" type is
preferable to a function attribute or a special out contract. In
regards to the first feature (allow functions to be marked as "no
return") they are all "semantically equivalent". They all
provide a way for the control-flow analyzer to know when a
function doesn't return and optimize the code surrounding it.
The second feature goes another step further by introducing the
"bottom type" into the language. This introduces new semantics
that define how non-returning functions interact with the type
system. Consider the following:
int main(string[] args)
{
return (args.length > 1) || assert(0);
}
This currently doesn't compile but will with the new "bottom"
type. Note that this example is another demonstration for why
these 2 features are orthogonal.
So the question of whether we should use a type/function
attribute/contract to mark functions as "no return" is a
different question than whether we should be introducing a new
bottom type. The 2 are conflated because if we do introduce a
new "bottom" type, then it means we will already have a way to
mark a function as "no return".
I would first try to answer whether or not we want the "bottom"
type. If the answer is yes, then we now have a way to mark
functions as "no return". If the answer is no, then we can use a
function attribute or special out contract.
More information about the Digitalmars-d
mailing list