Permalink
Browse files

* src/main/clojure/clojure/core/match.clj: clean up comparable? a bit

  • Loading branch information...
1 parent da48935 commit 17075bb1cd0cbdab080fbc98691080a5f07f88fc @swannodette swannodette committed Feb 25, 2012
Showing with 7 additions and 15 deletions.
  1. +1 −13 src/main/clojure/clojure/core/match.clj
  2. +6 −2 src/main/clojure/clojure/core/match/regex.clj
@@ -261,7 +261,7 @@
(defmethod comparable? :default
[x]
- false)
+ true)
;; =============================================================================
;; # Pattern Rows
@@ -1416,10 +1416,6 @@
(defmethod pattern-compare [PredicatePattern PredicatePattern]
[^PredicatePattern a ^PredicatePattern b] (if (= (.gs a) (.gs b)) 0 1))
-(defmethod comparable? PredicatePattern
- [x]
- true)
-
(defmethod pattern-compare [PredicatePattern WildcardPattern]
[^PredicatePattern a ^WildcardPattern b]
(let [p (.p a)]
@@ -1434,10 +1430,6 @@
(every? identity (map pattern-equals as bs)))
0 1)))
-(defmethod comparable? OrPattern
- [x]
- false)
-
(defmethod pattern-compare [VectorPattern VectorPattern]
[^VectorPattern a ^VectorPattern b]
(cond
@@ -1447,10 +1439,6 @@
(and (.rest? b) (<= (.size b) (.size a))) 0
:else 1))
-(defmethod comparable? VectorPattern
- [x]
- true)
-
;; =============================================================================
;; # Interface
@@ -1,6 +1,7 @@
(ns clojure.core.match.regex
(:use [clojure.core.match
- :only [emit-pattern to-source pattern-equals pattern-compare]])
+ :only [emit-pattern to-source pattern-equals
+ pattern-compare comparable?]])
(:import java.util.regex.Pattern))
;; # Regular Expression Extension
@@ -13,7 +14,6 @@
[pat]
(RegexPattern. pat))
-
;; Regular expressions are matched with `re-matches`.
;;
;; For example, given a pattern `#"olive"` and occurance `q`, a match occurs
@@ -35,3 +35,7 @@
(= (.flags ^Pattern (:regex a)) (.flags ^Pattern (:regex b))))
0
-1))
+
+(defmethod comparable? RegexPattern
+ [x]
+ false)

0 comments on commit 17075bb

Please sign in to comment.