They are not "the same": clojure.core/= ([x] [x y] [x y & more]) Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) as a value, not an identity, comparison. nil
= extends Java equals , since Java 5, primitives and their counterpart class types are equal. This a Java behaviour but the notion of equality has nothing to do with the boolean type representation in Clojure. The Boolean class is not used by Clojure to represent boolean values. It happens that the java false primitive matches the Clojure representation for false. The fact that Java considers the false primitive value to be the same as (Boolean. false) is irrelevant here. The same with true. In Clojure, a "true" value is non nil value. There is no Java equivalent behaviour. In Java, null is not the same as false. However nil and null are the same in Clojure, mainly to ease interop calls. The boolean JVM class IS NOT a Clojure type as per Clojure, it's a Java class, nothing more. Anytime you are using directly a class, you quit the Clojure world to dive in Java and therefore you are submitted to the rules of interop which have been devised to ease passing/referring to values between both worlds. This transparency may make you thing that this behaviour is odd but it's an illusion. > I fully support Steve Obua in his complains (although, I've never ran into > such issues myself). Also, I believe that most of answers for this topic > are slightly irrelevant; the problem is not java vs. clojure behaviour or > something, the problem is (at least for me) that > > (= (Boolean. false) false) ;=> true > > (if false :t :f) ;=> :f > (if (Boolean. false) :t :f) ;=> :t > > That's fucking weird!!! How the hell the *same* value can be both truthy > (in the first case) and falsey (in the second one)?! > > -- > 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 -- Softaddicts<lprefonta...@softaddicts.ca> sent by ibisMail! -- 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