Take a look at the macro expansion:
user=> (macroexpand '(.. (System/out) (print "-") (println "-")))
(. (. (System/out) (print "-")) (println "-"))
You are trying to call 'println on what ever 'print returns. But
'print is a void method.
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.
System/out
#<PrintStream java.io.PrintStream@7d59ea8e>
(System/out)
#<PrintStream java.io.PrintStream@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.
That patch seems to essentially reverse this one:
http://github.com/clojure/clojure/commit/5e9f2b293b307aa7953cd390360d24549e542b92
...which suggests to me there must be a better solution, though I
don't see yet what it would be.
--Chouser
Ok, it looks to me like the above commit was an insufficient
solution for the problem it was trying to solve. Since the
content of the finally block is emitted after the main try
block as well as after each catch block, a single finally handler
for all them together (which is what the above commit does)
cannot avoid potentially re-running some parts of the finally
clause.
To see what javac emits in similar circumstances, I wrote
a foo.java and disassmbled it here: http://gist.github.com/517865
It looks like javac protects the try block and each catch block
individually with separate entries in the exception table, all of
them pointing to the final finally block.
The patch at the top of that gist attempts to do the same thing,
and also fully reverses the earlier "endTryCatch" commit. This
passes all tests, including new ones Joe Gallo wrote based on
reports in this thread: http://gist.github.com/517871
--Chouser
http://joyofclojure.com/
You wrote some nice tests for these that could be included in
clojure-test, but I don't see your name on the contributor's
list: http://clojure.org/contributing
Have you sent in your CA?
--Chouser
http://joyofclojure.com/
Done and done: https://www.assembla.com/spaces/clojure/tickets/422
--Chouser
http://joyofclojure.com/