1.9.0-alpha10 includes the following changes since 1.9.0-alpha9:- NEW clojure.core/any? - a predicate that matches anything. any? has built-in gen support. The :clojure.spec/any spec has been removed. Additionally, gen support has been added for some?.
In clojure we are used to shortcuts involving not:(when-not x ...) => (when (not x) ...)(if-not x ...) => (if (not x) ...)(not-every? pred coll) => (not (every? pred coll))(not-any? pred coll) => (not (some pred coll))
However, the new function clojure.core/any? breaks this semantic pattern:> (doc clojure.core/any?)-------------------------clojure.core/any?([x])Returns true given any argument.> (doc clojure.core/not-any?)-------------------------clojure.core/not-any?([pred coll])Returns false if (pred x) is logical true for any x in coll,else true.These two functions are not only unrelated to each other, but they don't even accept the same number or type of arguments.
Moreover, there is an even more surprising property:> (clojure.core/any? nil)trueI would have bet money that, at least for nil, the result would not have been true.
Given the significant prior conventions in Clojure for functions like some, every?, *-not, not-*, and also the general handling of nil, it seems that the new any? function is bound to cause much confusion & consternation, especially among people learning Clojure.Given the degenerate definition:> (source clojure.core/any?)(defn any?[x] true)would it not be simpler and more instinctive to rename the function clojure.core/true:(defn clojure.core/true[x] true)
I can't think of a single use case where this function would be useful. I would either inline true instead of a function call, or I would supply (constantly true) if a function is expected.I am sure it wouldn't be included in core if there wasn't a valid reason. Could you tell me what is this function good for?
FWIW, I was not aware of `any?` when I read this thread, and I found its semantics confusing -- I think `anything?` would be much clearer. `anything?` also seems more obviously useful for defining specs (e.g. a function can take _anything_ as an argument). It seems usual in Clojure for scalar predicates such as int?, string?, rational? etc to have noun or adjective names, and collection predicates such as every? to have determiners such as every, some, any as names.
Logan