On Wed, Nov 17, 2010 at 10:26 PM, Victor - <bluestar...@gmail.com> wrote:
> On Wed, Nov 17, 2010 at 9:51 PM, Ken Wesson <kwess...@gmail.com> wrote:
>> Why not just have, in db.clj.
>>
>> (def somefunction mylib/somefunction)
>
> I used to do that before, but I realized I was introducing a level of
> indirection at a stage when the exact function signatures weren't clear yet.
> I do agree that the preferred final solution can well be to always call
> through function in the other namespace, though I think there may be
> exceptions..

If you're worried about having files that don't themselves :require or
:use mylib break if mylib/somefunction's signature changes, you can
add a real layer of indirection:

(defn somefunction [& args]
  (apply mylib/somefunction args))

and if mylib later changes, you can change db/somefunction to do
something more complicated when calling mylib/somefunction. JIT will
mostly kill the overhead of the extra indirection. Of course it's
still possible a change to mylib's somefunction will require changes
at all of db/somefunction's call sites and not just a change to
db/somefunction, but a kind of compilation-unit-granularity Law of
Demeter is at least observed now, where mylib changes may mean db
needs to change (db :requires or :uses mylib) and db changes may mean
foobar needs to change (foobar :requires or :uses db).

P.S. please don't top-post. It's a shame that the behavior of the
gmail/Google Groups interface seems to encourage top-posting; try to
resist this.

-- 
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

Reply via email to