I think this is not a bug in disj. disj takes a *set* and an element as input. nil is the empty seq, which is different from the empty set #{}. The fact that clojure.set functions work at all on things other than bona fide sets is, in Rich's words, "an implementation artifact and not a promise of the interface".
-Jason On Jan 29, 6:42 am, ntu...@googlemail.com wrote: > If its left argument is nil, "intersection" throws a NPE (Clojure rev. 1235): > > user=> (set/intersection nil #{1}) > java.lang.NullPointerException (NO_SOURCE_FILE:0) > user=> (.printStackTrace *e) > java.lang.NullPointerException (NO_SOURCE_FILE:0) > at clojure.lang.Compiler.eval(Compiler.java:4186) > at clojure.core$eval__3830.invoke(core.clj:1647) > at clojure.main$repl__5568$fn__5586.invoke(main.clj:148) > at clojure.main$repl__5568.doInvoke(main.clj:145) > at clojure.lang.RestFn.invoke(RestFn.java:426) > at clojure.main$repl_opt__5610.invoke(main.clj:208) > at clojure.main$main__5645$fn__5647.invoke(main.clj:295) > at clojure.main$main__5645.doInvoke(main.clj:289) > at clojure.lang.RestFn.invoke(RestFn.java:402) > at clojure.lang.Var.invoke(Var.java:332) > at clojure.lang.AFn.applyToHelper(AFn.java:172) > at clojure.lang.Var.applyTo(Var.java:453) > at clojure.main.main(main.java:39) > Caused by: java.lang.NullPointerException > at clojure.core$disj__3445.invoke(core.clj:915) > at clojure.core$reduce__3173$fn__3176.invoke(core.clj:549) > at clojure.core$reduce__3173.invoke(core.clj:547) > at clojure.set$difference__5658.invoke(set.clj:19) > at clojure.set$intersection__5661.invoke(set.clj:24) > at user$eval__259.invoke(Unknown Source) > at clojure.lang.Compiler.eval(Compiler.java:4175) > ... 12 more > nil > user=> (msg/select-messages msgs nil "OR" nil) > nil > user=> (set/intersection #{} nil) > #{} > > The same is true for clojure.set/difference and everything else that > uses clojure.disj with nil for the first parameter. > > Cheers, > nt --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---