On Friday, 6 December 2019 at 23:25:30 UTC, Johannes Loher wrote:
On Tuesday, 3 December 2019 at 10:06:22 UTC, Mike Parker wrote:
On Tuesday, 3 December 2019 at 10:03:22 UTC, Basile B. wrote:
That's interesting details of D developement. Since you reply
to the first message I think you have not followed but in the
last reply I told that maybe we should be able to name the
type of null. I think this relates to TBottom too a bit.
https://github.com/dlang/DIPs/blob/40352337053998885fbd0fe2718c300a322d3996/DIPs/DIP1NNN-DK.md
This is everything I wished for. It basically exactly resembles
the results of the lengthy discussion H. S. Theo and I had in
the review thread for Walter‘s original bottom type suggestion.
And it even covers a few additional details we had not thought
about. I can’t wait for this DIP to go into review. Thanks a
lot to the DIP author. You have my biggest respect for writing
a fleshed out proposal of this!
nice.
Kotlin has this as well, with Unit as void and Nothing as
noreturn.
So for example this compiles without complaint:
fun infinite(f: () -> Unit) {
while (true) {
f()
}
}
fun main() {
infinite { println(".") }
println("goodbye")
}
Where 'infinite' has an implcit Unit return type, but this
warns that the "goodbye" will never happen:
fun infinite(f: () -> Unit): Nothing {
while (true) {
f()
}
}
fun main() {
infinite { println(".") }
println("goodbye")
}
This might be more important for resources that never get
closed, or secrets are never scrubbed from memory, due to
someone putting those tasks after a function like 'infinite'
without noticing.
... noreturn local variables are pretty gross, though.