| > I don't know what you mean by this. An Iterable<X,Nothing> cannot return Null from its first attribute. Check the declaration of Iterable.first. This made me sad again[1], but then this made me happier[2] (internalFirst implied it is defined in the compiler, finding all of the pieces that make up the definition was a bit of a pain since it is dispersed across so many files), but I think I didn't fully understand union types (and that Nothing was bottom) when I wrote the grand parents logical conclusions. :t Iterable<X,Nothing>.first ==>
X|Nothing ==>
X (because union with empty is an identity)
therefore inside max, the variable first will have type X when given an Iterable<X,Nothing>.first. I also see how it cannot be re-written as I proposed because there is no guarantee that Absent will be of type Null.> That's not correct. Go and check the definition of Null. It's just a regular class, as advertised. There is no special behavior defined in the language spec. Sure, the exists operator is defined by the language spec to mean "is Object", but that's just trivial syntax sugar. I did check the definition of Null, I was merely pointing out that although it is a user definable type, the language specification does mention its existence here[3] and here[4] which is where I looked to try to find out what the "exists" keyword meant. Specifically: in the case of an exists condition, a type whose intersection with Null is not exactly Nothing and whose intersection with Object is not exactly Nothing, or
Later on it says "exists x is equivalent to is Object x, and..." but then why reference Null earlier?> I guess the problem here is that you're used to languages full of weird special cases and ad hoc behavior. While I thank you for your time answering my mis-understandings of union types, please do not shoe horn me.
My main programming activities are using OCaml and Haskell, both of which have very few ad-hoc language features, if any. [1]: http://modules.ceylon-lang.org/repo/1/ceylon/language/1.0.0/... [2]: https://github.com/ceylon/ceylon.language/blob/master/src/ce... [3]: http://ceylon-lang.org/documentation/1.0/spec/html_single/#c... [4]: http://ceylon-lang.org/documentation/1.0/spec/html_single/#a... |
Sure, the language spec _mentions_ Null, in order to define the syntax sugar X? and exists x. But that doesn't mean that Null has any special place _in the type system_.
> My main programming activities are using OCaml and Haskell, both of which have very few ad-hoc language features, if any.
OK, great, sorry for making assumptions. In my defense, I just didn't quite understand why you were having such a hard time believing that Ceylon could do things like this without adhoc special cases.