On Thu, Apr 19, 2012 at 2:46 PM, Ambrose Bonnaire-Sergeant
<abonnaireserge...@gmail.com> wrote:
> Hi,
>
> I've been doing some thinking about the treatment of nil in a
> statically typed version of Clojure.
>
> It occurs to me that nil is significantly different to Java's null
> reference, which
> is almost a Bottom type.
>
> Java's null is a subtype of any reference type.
> Clojure's nil is just nil, subtype to nothing except itself.
>
> To accomodate this, nil should be implicitly added to the result
> type of any interaction with Java via interop.
>
> (Union syntax: (U x0 .. xn) is the union of types x0..nx)
>
> <expr> :- <type of expr>
>
> (Integer. 1) :- (U java.lang.Integer nil)

Constructor calls can never evaluate to null.

> (.getClass 1) :- (U java.lang.Class nil)

I'm pretty sure the Object#getClass method can never return null either.

On the other hand,

(.get a-java-util-map foo) :- (U java.lang.Object nil)

:)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to