Thanks, everyone, your responses are very helpful and much appreciated.

On Thu 10/27/16 09:57AM, lvh wrote:

> comp takes a number of functions and returns a function. Threading macros 
take a
> number of forms (expressions) and return an expression. The threading 
macro does
> not need a partial, because it operates on the form and injects something 
in it
> (in the second position for ->, last position for ->>). The comp version 
does
> need a partial, because `(interpose \-)` is not a function — it is just a 
form.

On Thu 10/27/16 03:00PM, Gary Trakhman wrote:

> Comp does its work at run-time, so you have to call functions that return
> functions.  Threading macros do their work at compile-time, so your form
> literally compiles to this:

These points are helpful for me to keep in mind:

* `comp` works with functions, and `->>` works with forms.

* `comp` is runtime, while `->>` is compile-time. The arguments to `comp` 
will
   be evaluated at runtime and should be callable functions.

Looking at the macro expansion of `->>` is very helpful and straightforward 
to
understand. The `->>` macro will setup an expression at compile-time that 
will
be evaluated all at once during runtime.

For `comp`, at runtime, `(map str/lower-case)` and `(interpose \-)` will 
return
transducers, and `partial` is needed to create the intended function, e.g.,
`str/lower-case` bound to `map` and expecting a collection argument.


-- 
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/d/optout.

Reply via email to