DIP 1017--Add Bottom Type--Final Review
aliak
something at something.com
Wed Jan 16 04:20:42 UTC 2019
On Tuesday, 15 January 2019 at 22:44:56 UTC, Johan Engelen wrote:
> The link does not really have answers that explain the use of a
> bottom type in a practical imperative language, beyond that it
> signifies `noreturn`.
> The question we have is whether there is a compelling use for
> "bottom". I'd like to see a real code use case, besides
> signifying `noreturn` (trivial).
A very practical use case is with error code paths where you end
up asserting/exiting the program, something like:
int f(int i) {
if (i) {
exit(0);
} else {
return 0;
}
}
D currently special cases assert(0) for that. But practically you
can have function other than a special cased assert that never
return. Without the bottom type I'd have to write "return
make-up-a-number" and then if there's a bug in "exit" i could be
returning make-up-a-number and using it and I'd never be the
wiser.
More information about the Digitalmars-d
mailing list