Do we want a predicate for every interface? I, for one, DEFINITELY do not. Just make some utils if you need to check for (instance? IAtom x) a lot in your application. All such fns do is bloat clojure.core.
On Sun, Jul 16, 2017 at 5:24 PM, Alex Miller <a...@puredanger.com> wrote: > The decisions for volatile? vs other predicates were made at different > times so I don't think there is necessarily any guiding design principle > behind having one vs not having the other. I wrote the volatile addition, > but I don't remember any of the details around why we included volatile? at > that time. > > The broader question is, do we need a predicate for every interface? Is > this worth having vs just #(instance? clojure.lang.IAtom %). One reason a > predicate can be useful is for portability with ClojureScript, so I think > that adds a little more weight to atom? (and none for ref? or agent?). > > Another question is where this would be useful - what could do you > envision where it's helpful to have it. If it's not common, then it's not > worth having yet another function in core that needs to be loaded. > > And another question is how prevalent this function is "in the wild" > either as a predicate or even more interestingly as something else. > clojure.inspector and cider.nrepl actually have an atom? that is more of > the traditional lisp/scheme sense of a non-collection. I see other impls of > atom? in places like plumatic schema, taoensso encore, hara.common.checks, > seesaw, and many others. (All of those impls are actually dated in that > they check for the concrete class Atom rather than the interface IAtom that > was introduced in 1.7.). See https://crossclj.info/clojure/atom%3F.html > for more definitions. > > Having many existing impls of this function out there means that we either > introduce warnings, or worse we actually introduce a core function that has > different semantics - there are many similar functions that instead check > for Atom, and some that do something entirely different. > > Weighing all this, I can't say that adding atom?, ref? (likely to have way > more conflicts with different semantics), or agent? seems like a big win to > me and is certainly not problem-free. When we added volatile?, that was not > an existing overlap with many (or maybe any) existing functions out in the > wild so was a little easier from that perspective. > > On Sunday, July 16, 2017 at 3:38:47 PM UTC-5, Shantanu Kumar wrote: >> >> Hi, >> >> Since Clojure 1.7 there's a `volatile?` predicate function, but no such >> equivalent for atom/ref/agent. Can anybody explain the rationale behind the >> difference? I found an old thread on a related topic (URL below) but would >> like to know if there's an updated explanation. >> https://groups.google.com/forum/#!topic/clojure/mIJK3x_SUyM >> >> >> Shantanu >> > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.