Skip to content

Commit

Permalink
equiv-based =, equiv overloading for Util
Browse files Browse the repository at this point in the history
  • Loading branch information
richhickey committed Jun 23, 2010
1 parent 0df995d commit df0e4b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/clj/clojure/core.clj
Expand Up @@ -698,7 +698,7 @@
([x y] (clojure.lang.Util/identical x y)))

;equiv-based
#_(defn =
(defn =
"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
Expand All @@ -717,7 +717,7 @@
false)))

;equals-based
(defn =
#_(defn =
"Equality. Returns true if x equals y, false if not. Same as Java
x.equals(y) except it also works for nil. Boxed numbers must have
same type. Clojure's immutable data structures define equals() (and
Expand Down
24 changes: 24 additions & 0 deletions src/jvm/clojure/lang/Util.java
Expand Up @@ -59,6 +59,30 @@ static public boolean equals(double x, Object y){
static public boolean equals(Object x, double y){
return equals(x,(Double)y);
}

static public boolean equiv(long x, long y){
return x == y;
}

static public boolean equiv(double x, double y){
return x == y;
}

static public boolean equiv(long x, Object y){
return equiv(Numbers.num(x),y);
}

static public boolean equiv(Object x, long y){
return equiv(x,Numbers.num(y));
}

static public boolean equiv(double x, Object y){
return equiv((Double)x,y);
}

static public boolean equiv(Object x, double y){
return equiv(x,(Double)y);
}
//*/

static public boolean identical(Object k1, Object k2){
Expand Down

0 comments on commit df0e4b6

Please sign in to comment.