Hi Brian, System/out #<PrintStream java.io.printstr...@7d59ea8e> (System/out) #<PrintStream java.io.printstr...@7d59ea8e>
both return the "out" PrintStream object, so (.. System/out (print "-")) -nil (.. (System/out) (print "-")) -nil (.. System/out (print "-")) -nil all invoke the print method on the java PrintStream object and correctly return nil as does... (.print System/out "-") -nil which is the alternative way of invoking a method on a java object. Your (doto (System/out) (.print "-") (.println "-")) -- works correctly as you're calling the two print methods on the System/out object, but your (.. (System/out) (print "-") (println "-")) is trying to pass the result of the 2nd (println "-") as a extra arg to the call, hence the bomb. So actually it's nothing to do with try/finally. -Hth, Adrian. On Tue, Aug 10, 2010 at 8:36 AM, Brian Stiles <brian.sti...@gmail.com> wrote: > The following succeeds: > > (try > (prn 1) > (finally > (prn 2) > (doto (System/out) (.print "-") (.println "-")))) > > prints: > > 1 > 2 > -- > > The following fails (note the odd duplication of "2" in the output): > > (try > (prn 1) > (finally > (prn 2) > (.. (System/out) (print "-") (println "-")))) > > prints: > > > 1 > 2 > -2 > -Exception in thread "main" java.lang.NullPointerException > (NO_SOURCE_FILE:0) > at clojure.lang.Compiler.eval(Compiler.java:4658) > at clojure.core$eval__5236.invoke(core.clj:2017) > at clojure.main$eval_opt__7411.invoke(main.clj:227) > at clojure.main$initialize__7418.invoke(main.clj:246) > at clojure.main$null_opt__7446.invoke(main.clj:271) > at clojure.main$main__7466.doInvoke(main.clj:346) > at clojure.lang.RestFn.invoke(RestFn.java:426) > at clojure.lang.Var.invoke(Var.java:363) > at clojure.lang.AFn.applyToHelper(AFn.java:175) > at clojure.lang.Var.applyTo(Var.java:476) > at clojure.main.main(main.java:37) > Caused by: java.lang.NullPointerException > at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:26) > at user$eval__1.invoke(NO_SOURCE_FILE:1) > at clojure.lang.Compiler.eval(Compiler.java:4642) > ... 10 more > > -- > 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 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