On Fri, Jan 23, 2015 at 1:10 AM, Luc Prefontaine <
lprefonta...@softaddicts.ca> wrote:

> Agree, it's broken... in java...
>

I think it's more frustrating in Clojure than in Java, though, because in
Java you have those big, ugly type annotations on every single variable,
input and output, so there's really no question when you're working with a
mixture of floats and doubles.  In Clojure, it's much easier for this kind
of thing to slip into your program unnoticed.  Call a couple of external
libraries that produce floats or doubles -- Clojure will happily hide the
difference from you and then you get burned.

As I frequently find myself explaining to newcomers to Clojure, one of
Clojure's biggest weaknesses is that it goes to great pains to hide type
details (floats vs doubles, boxed vs unboxed, hash sets vs array sets,
etc.) and every once in a while it really matters -- a lot -- what the
types actually are and there aren't many tools for discovering the flow of
types through your code.

So I wouldn't necessarily go blaming this on Java.

Furthermore, I'm not so sure it is broken in Java:

=> (.equals (float 2) (double 2))
false

=> (.compareTo (float 2) (double 2))
ClassCastException Cannot cast java.lang.Double to java.lang.Float
java.lang.Class.cast (Class.java:3258)

So Java doesn't appear to transparently treat floats and doubles as equal
(which is consistent with the fact that Java's hashes of floats and doubles
can be different).

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to