4 ms·
this is called a bottom type in a type system. In JVM languages null and the throw expression return the bottom type. The only other option is to not have nil
by p4lindromica 9y ago
this is called a bottom type in a type system. In JVM languages null and the throw expression return the bottom type.
The only other option is to not have nil values.
- kobeya 9y agoOr to encapsulate a nil in a Maybe monad, so that you only have to deal with it in contexts where you explicity denote acceptance of nils. Then the type system won't let you get away with ignoring the possibility of a nil.
- deleted 9y ago[deleted]
- p4lindromica 9y agoyou can do a maybe monad without nil types by substituting nil with a single-valued singleton type
- junke 9y agoThe problem is "null" being a value in all (non primitive) types, not only the bottom type. You specify "String", but you can have "null" too. When everything is optional, how do you specify that function foo really takes a String, not null? (https://stackoverflow.com/questions/4963300/which-notnull-java-annotation-should-i-use?rq=1 https://stackoverflow.com/questions/4963300/which-notnull-ja...)
- the8472 9y ago> The only other option is to not have nil values. Rust has a bottom type (!)[0] without it implementing all traits by default while using a different type (Result) for error propagation. Plus having nil/null as a a value of the bottom type violates some aspects of bottomness. [0] https://github.com/rust-lang/rfcs/blob/master/text/1216-bang-type.md https://github.com/rust-lang/rfcs/blob/master/text/1216-bang...