dcolthorp / matchure

Powerful, idiomatic pattern matching for clojure
159 stars 8 forks source link

add match? predicate #1

Open swannodette opened 14 years ago

swannodette commented 14 years ago

You have if-match, but why not add a match? predicate.

dcolthorp commented 14 years ago

I've considered the same thing, and may add it. The only reason I haven't is that it would have to be a macro, not a function. This means you wouldn't be able to use it like a function in all but the most basic case. For example, you couldn't pass match? to another function or curry it with something like

(def my-matcher (partial match? [java.lang.String & _]))

No one expects to this type of thing with an if, cond, or when form.

fdserr commented 11 years ago

Illumination: "The only reason I haven't is that it would have to be a macro, not a function. This means you wouldn't be able to use it like a function in all but the most basic case." Thanks Drew!