Feedback Thread: DIP 1034--Add a Bottom Type (reboot)--Community Review Round 1
Dennis
dkorpel at gmail.com
Mon May 11 10:18:44 UTC 2020
On Monday, 11 May 2020 at 08:48:47 UTC, Piotr Mitana wrote:
> noreturn look more like a keyword also due to its similarity to
> return keyword.
I don't see a problem with that. Many syntax highlighters
highlight `string` like a keyword. The fact that it's technically
an alias is unimportant.
> noreturn suggests clearly that the function will not return,
> but it is natural only for this use of the bottom type, and as
> the DIP states, there are more uses.
Just about the only time you actually need to spell out the
bottom type is when marking a function to not return, so the name
is tailored to that use case.
```
// Why write a non-template function like this?
noreturn[] getEmptyArray() {return [];}
void takesNullPointer(noreturn* ptr) {}
// This is what you actually write
noreturn panic(string msg) {assert(0, msg);}
```
> Although returning nothing is a little bit less clear that
> noreturn, everyone knows void, so it has to be something
> different.
So `nothing` is synonymous with `void`, but people are familiar
with `void` so they'll figure `nothing` must refer to something
different than `void`, such as `noreturn`. I have my doubts about
that. I think it will be confusing, while `noreturn` is clear as
day.
> And nothing[] looks much more in place then noreturn[].
If I really needed to spell it out in non-generic code, I would
just write `typeof([])`, and for `noreturn*` use `typeof(null)`
(which is the name the compiler uses currently).
More information about the Digitalmars-d
mailing list