Details
-
Type:
Defect
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
Using ClojureScript f4c0de502c92ce710da923888d672f22213b902c (checked out on Thu Jan 19 2012)
=> (= 1)
false ;; incorrect
=> (= 1 1)
true
=> (= 1 1 2)
true ;; incorrect
=> (= 1 1 1)
true ;; correct, but by accident
In Clojure and according to Clojure's API = is defined for all arities [1,2]
=> (= 1)
true
=> (= 1 1)
true
=> (= 1 1 2)
false
The source of this bug is that = is only implemented in ClojureScript for the 2 arity [3]. Combined with the javascript behaviour for superfluous arguments this leads to these unfortunate results. Implementing = for multi arities in ClojureScript by following the Clojure implementation should fix this. See for example the <
predicate in ClojureScript [4].
[1] = API - http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/=
[2] = in clj - https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L719
[3] = in cljs - https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L180
[4] < in cljs as an example of a multi-arity predicate - https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L801
Just to clarify = is the generic equivalence test, the numeric operator == supports what you're describing just fine.