Hi Joseph,

> I have recently come a cross a number of references to Clojure's
> threading macros, -> and ->>. These macros have the form: ((or -> ->>) x
> form ...). The value of x is spliced in as the first or last argument,
> respectively, of form with its result being likewise spliced into the
> next form and so on. From the examples I have seen, these macros can be
> useful, but instead of replicating these macros exactly in bigloo, I
> decided to create a generalized version called T> where _ is used to
> indicate where values are to be spliced in. T> has the form: (T> x form1
> ...) In form1 and subsequent forms the _ character is used to indicate
> where x should be spliced.
> 
> Examples:
> 
> (T> 4 (+ _ 3) (* 3 _)) => 21
> 
> (T> '( 1 2 3 4) 
> (map odd? _) 
> (map (lambda (x) (* x 2)) _))  => (2 6)
> 
> The definition of T> is attached. I would be interested in any comments
> or suggestions you may have.
I don't understand your example. I would have replaced MAP with FILTER, as 
in:

  (T> '( 1 2 3 4) (filter odd? _) (map (lambda (x) (* x 2)) _))

What are the concrete use cases they have in Clojure for this macro?
It vaguely reminds me of the monadic threads as one may find in Ocaml. 

-- 
Manuel

Reply via email to