Hi, as David has said, your macro works only for literal values, which doesn't make much sense.. I would implement i-let as follows:
(defmacro let-default [bindings & body] `(let ~(vec (mapcat (fn [[sym value default]] `(value# ~value ~sym (if (nil? value#) ~default value#))) (partition 3 bindings))) ~...@body)) Please note also like Laurent stated, that the `or` trick doesn't really work on such such a general macro or you will be limited to non-boolean values! This leads to the need of `if`. And this in turn leads to the need of `gensym` (via #), because otherwise the "value" is computed twice. As for the question for the return type of the seq functions: Returning a seq allows them to be lazy. This is not only an issue of the input (the eg. vector is already in the memory anyway), but also of the number of traversals. Consider the following: (map dec (filter #(> % 5) (map inc (some-vector here)))) Would map and filter return vectors because the input is a vector, the following would happen: 1. map traverses the vector, incs its elements and creates a new vector 2. filter traverses the new vector, removes elements eventually and creates a new vector 3. map traverses the new vector, decs its elements and creates a new vector So you basically traversed the vector 3 times. While in the current setup (wrapping the chain in an explicit `vec`) traverses the vector only once. Minor issue: you create more garbage in form of temporary vectors which are thrown away almost immediately. Hope this helps. Sincerely Meikel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---