Because this tests for something different - that the element is an instance of ClSymbol. It's not testing the same thing as the core version. I qualify it (psi/symbol? in the examples above) to distinguish it from the core one.
Basically, I'm trying to use definline to allow me to have a more Clojure-y API without having the performance hit of tons of tiny function calls. I agree that this is unlikely to be a bug in Clojure and is probably something I'm missing, but I can't figure it out. Cheers, Colin On 20 June 2013 21:47, Jim - FooBar(); <jimpil1...@gmail.com> wrote: > There is already a symbol? predicate in core. Why are you defining your > own? Does your problem disappear when you use the one from core? > What exactly are you trying to do? I use definline quite frequently and > have never encountered such problems... > > Jim > > > > On 20/06/13 10:35, Colin Fleming wrote: > > Hi all, > > I'm having a problem where a definline'd function is not working when > used as a predicate for filtering. It seems to work sporadically - > occasionally it works, occasionally it doesn't. I'm thinking it's probably > a compile problem since it seems to work or not work consistently for each > compile (i.e. if it's not working and I recompile, it may work). > > The predicate looks like this: > > (definline symbol? [element] > `(instance? ClSymbol ~element)) > > I'm using it like this: > > (defn all-symbols [coll] > (filter psi/symbol? (psi/children coll))) > > And calling all-symbols like this: > > (map (fn [sym] > (if-let [target (symbols (name sym))] > [sym target])) > (all-symbols exclude)) > > I then get an exception that one of the elements in the collection > doesn't implement Named, which ClSymbol does. > > I also tested this in the repl: > > Clojure 1.5.1 > (in-ns 'plugin.psi) > => plugin.psi > (symbol? 2) > => false > (filter symbol? [1 2 3]) > => (1 2 3) > > Am I missing something obvious here? > > Thanks, > Colin > -- > -- > 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/groups/opt_out. > > > > > -- > -- > 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/groups/opt_out. > > > -- -- 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/groups/opt_out.