> I like that implementation. The recursive call makes it much cleaner. > A slight improvement (?) yet: > > (defmacro let-> > "Provide a name that will be bound to the result of the first form. > For each additional form, the variable will be > used in the evaluation, and then rebound to the result of the > form." > ([varname start] start) > ([varname start & forms] > `(let [~varname ~start] > (let-> ~varname ~...@forms))))
Yes, even better :) > But just because the second can be expanded into the first, doesn't > mean that is what is clojure is doing behind the scenes (and a quick > investigation shows it is not). > > I could argue it either way on the efficiency angle. On one hand it > seems like a function call would be more expensive than pushing > variables on the stack that clojure uses to keep track of bindings. On > the other hand, I'm sure HotSpot can work wonders with tiny little > inline-able functions in repeated code. My vote is for the cleaner > implementation. Well, given that quick tests showed them to be within 5% of each-other on the examples you gave, maybe both end up the same after Hotspot does its magic. In the absence of any other reasons, I'm with you in choosing the cleanest solution (i.e., the one you just posted). -Jason --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---