Ken Wesson <kwess...@gmail.com> writes: Hi Ken,
> A related case may be when you're not making just a straight wrapper, > but adding something -- your own pre/post checks, or argument > transformations, or etc. > > As for binding to a Var, that makes sense if the result is not as > trivial as #(.meth %) and is going to be used many times. Otherwise > #(.meth %) is not much longer than a reasonably clear Var name for it > and is crystal clear as to what it does, so I'd just use that. Another consideration I take into account is if a functionality is exposed to users. For example, I have a clojure graph querying and transformation library that is built upon our java graph library. The functionality is hopefully implemented in idiomatic clojure, like iterating nodes and edges using lazy seqs. However, there are two or three functions that basically wrap only java methods. I decided to put them in although it's idiomatic clojure to call java, because then the user gets a complete, consistent clojure API and doesn't have to know anything about the java side. For example, you can write --8<---------------cut here---------------start------------->8--- (reduce + (map #(value %1 :inhabitants) (vseq (rg) 'localities.Locality))) --8<---------------cut here---------------end--------------->8--- instead of the slightly alien --8<---------------cut here---------------start------------->8--- (reduce + (map #(.getAttribute %1 "inhabitants") (vseq (rg) 'localities.Locality))) --8<---------------cut here---------------end--------------->8--- That's a bit shorter (and allows for giving the attribute name as keyword, symbol, or string), and most importantly it is documented. If that wrapper wasn't there, users that just want to use the clojure library have to study the javadocs, too. Bye, Tassilo -- 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