Re:Kotlin 1.1: What’s coming in the standard library
by hota_mazi on Thursday January 26, 2017 @11:50PM
(#13497794)
> (you can either assume all Java calls are non-null unless checked, assume all Java calls are nullable and force checking, or trust annotations; all these approaches suck in their own way)
Agreed, which is why Kotlin has explored all of these options and ending up implementing neither.
Look up "platform types".
Re:Kotlin 1.1: What’s coming in the standard library
by lmm on Friday January 27, 2017 @05:03AM
(#13498823)
Oh my god. I didn't think it was possible to do worse than all three approaches I mentioned, but they found a way.
> Platform types are non-denotable, meaning that one can not write them down explicitly in the language.
But the right way to represent absence - whether you call it null or option or something else - is clearly with a normal type that follows the normal rules of the language, not a special language-builtin type with special language-builtin rules. Some light syntactic sugar for commonly-used types makes sense (like Ceylon's "?"), but what it desugars to should always be something you could write a normal library type for. Indeed if your language doesn't let you implement the constructs you need for this kind of type in a custom type in a library, that should be a red flag that your language isn't expressive enough for general-purpose use.