Share your thoughts in the 2024 State of Clojure Survey!

Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

From time to time, I see that I reimplement named? as a predicate:

(defn- named? [a]
  (instance? clojure.lang.Named a))

Would this be a reasonable addition to Clojure?

1 Answer

+1 vote
by
selected by
 
Best answer

Interestingly, there is a closed issue that mentions named? https://clojure.atlassian.net/browse/CLJ-1298

Some of the suggested predicates have been implemented, some haven't been. named? is in the latter list.

by
Thanks for highlighting this older ticket. There's some interesting historical discussion in it worth checking out. To wind back around to the present let me say that we typically will not add something to Clojure just because it doesn't exist but instead try to address clear bugs and solve problems that users encounter.
by
FWIW, I used to find myself writing this all the time but I no longer find I need to since the addition of ident? in 1.9 (and since I discovered that name works on strings -- since 1.2!)
by
The other predicates in CLJ-1298 were considered in 1.9 timeframe and if they weren't included it's because we decided not to include them, so this has been considered.
...