> i stumbled over two odd things > 1) -> and ->> have the same source code. why is that?
The source code is _not_ the same for the two macros you mentioned. I will leave it to you to spot the differences ;-) > 2) why can't i use "(-> "hi" #(println %))" directly? why do i have to > put my function into a symbol first? is there a way to avoid this? > > (let [dummy #(println %)] > (->> "hi" dummy)) You don't need to "put the function into a symbol", all you need is an extra set of parentheses - (->> "hi" (#(println %))) ;=> hi ;=> nil In your case, the reader macro # is converting your form into a function object _before_ macro-expansion time. The ->> macro sees that it's not a seq and adds a set of parens around it automatically but the semantics of the form is getting altered to something like this - (fn [x] (println x) "hi") And thus, it's not working as you expect it to. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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