Let me amend:
Instead of pipe-as, I think the symbol-binding version of the macro
should be derived from the more common macro, which is -> & not pipe.
So I'd vote for pipe & a let-> that takes a bindings vector as its
first argument (sample implementation below).
Perry
(defmacro let->
"Like ->, but takes a binding form as first argument, the bound
symbol(s) from
which will carry the resulting value from form to subsequent form.
E.g.
(let-> [a 1] (str "Your number is:" a) (.replace a "Your"
"My") .toUpperCase) =>
\"MY NUMBER IS: 1\""
([[sym init] form]
(if (seq? form)
`(let [~sym ~init] ~form)
(list 'let [sym init] (list form sym))))
([[sym init] form & more]
`(let-> [~sym (let-> [~sym ~init] ~form)] ~...@more)))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---