Before 1.9.0 is officially released, I would like to propose a revisit to the semantic mismatch introduced by the clojure.core/any? function.
Many, many people are dissatisfied by the choice of clojure.core/any? to be defined as (constantly true), which is completely in conflict with clojure.core/not-any? . After all, any logical person would automatically assume that:
(= (not-any? args...) (not (any? args...))
for any set of legal arguments. This follows the well-established tradition in Clojure of having negated pairs such as if vs if-not, when vs when-not, every? vs not-every?, etc.
However, I can see that it is convenient to say something like this:
(s/fdef clojure.core/declare
:args (s/cat :names (s/* simple-symbol?))
:ret any?)
It seems a simple solution to the problem would be to just define some keyword specs in place of the globally visible any? function. The following example shows that we could define :clojure.spec/pass-all and :clojure.spec/pass-none which would could serve as an exact replacement for any? (& its negative).
(:require [clojure.spec.alpha :as s] ...)
(deftest demo
(s/def ::s/pass-all (constantly true))
(s/def ::s/pass-none (constantly false))
(is (s/valid? ::s/pass-all 5 ))
(is (s/valid? ::s/pass-all "joe" ))
(is (s/valid? ::s/pass-all { :blah 42 :blue 66 :hut! 'hut! }))
(is (not (s/valid? ::s/pass-none 5 ))))
Since 1.9.0 is not out yet, is not too late to avoid a permanent pollution of the language with a gigantic mistake such as any?. At the very least, the function could be moved to clojure.spec/any? from clojure.core. If we insist on adding this blatant contradiction to clojure.core, we won't even have the excuse of a committee to blame it on.
Alan Thompson