Permalink
Browse files

Fix usage of root-type

  • Loading branch information...
1 parent ff0ff6f commit 42134c6a583522beeedb8cdac2c15e4f490b21d0 @khinsen khinsen committed Sep 5, 2011
@@ -39,7 +39,8 @@
; We can't use [::binary :default], so we need to define a root type
; of the type hierarcy. The derivation for Object covers all classes,
; but all non-class types will need an explicit derive clause.
-; Ultimately, a macro might take care of this.
+; Since non-class types are rare since Clojure 1.2, this need is
+; not likely to be frequent.
;
(def root-type ::any)
(derive Object root-type)
@@ -178,7 +178,7 @@
[x]
(clojure.core/neg? x))
-(defmethod = [Object Object]
+(defmethod = [root-type root-type]
[x y]
(clojure.core/= x y))
@@ -9,13 +9,11 @@
;; remove this notice, or any other, from this software.
(ns clojure.algo.generic.test-collection
- (:use [clojure.test :only (deftest is are run-tests)]
- [clojure.algo.generic :only (root-type)])
+ (:use [clojure.test :only (deftest is are run-tests)])
(:require [clojure.algo.generic.collection :as gc]))
; Define a multiset class. The representation is a map from values to counts.
(defrecord multiset [map])
-(derive multiset root-type)
(defn mset
[& elements]
@@ -40,7 +38,6 @@
; Define a sparse vector class. The representation is a map from
; integer indices to values.
(defrecord sparse-vector [map])
-(derive sparse-vector root-type)
(defn s-vector
[& values]
@@ -9,16 +9,13 @@
;; remove this notice, or any other, from this software.
(ns clojure.algo.generic.test-comparison
- (:use [clojure.test :only (deftest is are run-tests)]
- [clojure.algo.generic :only (root-type)])
+ (:use [clojure.test :only (deftest is are run-tests)])
(:require [clojure.algo.generic.comparison :as gc]))
; Define a class that wraps a number.
(defrecord my-number [value])
(defn n [value] (new my-number value))
-(derive my-number root-type)
-
; Implement the minimal comparison multimethods.
(defmethod gc/zero? my-number
[x]

0 comments on commit 42134c6

Please sign in to comment.