On Mar 11, 8:35 am, Alan <a...@malloys.org> wrote: > > Suppose I need mathematical 2D vector functions: > > > (ns geometry.vector) > > > (defstruct vector :x :y) > > > (defn + > > "Add vectors v and w, yielding a vector" > > [ v w ] > > (...)) > > > Which leads to the core "vector" function being shadowed by my struct > > and the core "+" function shadowed by my function. What is the > > idiomatic Clojure approach for handling this situation? Is it through > > careful use of :require and :import parts of a (ns ...) form?
> user=> (ns math (:refer-clojure :rename {vector cvector})) > nil > math=> vector > java.lang.Exception: Unable to resolve symbol: vector in this context > (NO_SOURCE_FILE:0) > math=> (def vector identity) > #'math/vector > math=> (vector 10) > 10 > math=> (cvector 10) > [10] Thanks for that -- please bear with me on this: does that mean that given the flexible options available in the (ns...) form as shown here, Clojure developers don't need to choose non-shadowed names like <vector> or (defn vector+), but rather use the more natural forms and use (ns...) clauses to make everything clear as needed? Thanks, Stu -- 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