On 11.02.2009, at 18:18, Perry Trolard wrote:

> In any case, I vote for approaching Konrad Hinsen about putting this
> in clojure.contrib.macros when a naming convention is agreed on.

When I started clojure.contrib.macros, I intended it as a repository  
for everybody's small macros that don't have any other obvious place.  
So I don't mind anyone on the clojure.contrib group adding whatever  
they seem fit.

BTW, I completely agree about the utility of the pipe macro, though I  
can't make up my mind about which syntax I would prefer. I remember  
that Paul Graham discusses such a macro in On Lisp, using "it" as the  
parameter, but I forgot what is macro is called.

I have a similar operation in my monad library, which is called m- 
chain. It expects a list of monadic operations that are functions of  
one argument, the result being again a function of one argument  
representing the composite operation. Using this operation in the  
identity monad would yield something quite close to the pipe macro  
being discussed, but as a function. Example:

(def my-pipe
   (with-monad id
     (m-chain #(filter odd? %)  #(map inc %)))

(my-pipe (range 10))

The advantage of such an approach is that there is no new syntax  
rule: the parameter placeholder is the well-known %. Another  
advantage is that it can be written as a function. Of course, the  
drawback is that all those functions cause a run-time overhead. Plus  
a macro makes for shorter syntax, which is part of its purpose.

As you can see, I am fully undecided :-)

Konrad.


--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to