Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

16
  • 2
    Yes, for most languages, documentation, convention and consistency should be the way how to "solve" this (e.g. by using a specific method suffix). For other languages actually supporting a mechanism to represent a method which never terminates, such mechanism should be used.
    – Andy
    Commented Aug 19, 2020 at 13:42
  • 22
    @Fred void at least in C, C++, and many similar languages just means the function doesn't return a value, but provides no indication on whether or not the function actually returns. A bottom type is a type that cannot be instantiated. A function that returns a bottom type cannot return without providing an instance of the bottom type, but since bottom cannot be instantiated, it must diverge, i.e. loop forever, throw an exception, power off the machine, etc.
    – 8bittree
    Commented Aug 19, 2020 at 14:21
  • 11
    @Fred: void signifies that a function does return, but doesn't return a useful value. never signifies that a function doesn't return. The equivalent to void in a more expressive type system would be a unit type, i.e. a type which has only one instance and no useful operations. Commented Aug 19, 2020 at 15:05
  • 4
    Haskell's is called Void. A fairly standard name is "empty type", which doesn't imply subtyping like "bottom type". C (and friends)'s void can be seen as having a single value (therefore no information; if you know something is void you know its value), that you just can't name. The identity of that single value is not important. In Java/Scala, the Null type (which is unnamed in Java) contains only the value null, but it's different from Scala's Unit, which has a different singleton value. "Jump type" seems... too specific? Maybe "unreachable".
    – HTNW
    Commented Aug 19, 2020 at 22:39
  • 2
    @Steve: there is standardization, mostly. Both the type and the value for a function that returns no useful value is almost universally called unit. It is only a small number of languages that deviate from that and call it void. Although note that the concept of void in e.g. C is very different, because it is not actually a type, it is more of a marker. In particular, in languages like Scala, there are no statements, there are only expressions. What would be a statement in C or Java is still an expression in Scala, just one whose value is unit. Commented Aug 20, 2020 at 0:39