2010/1/27 Seth <seth.schroe...@gmail.com>:
> Michael,
>
> Thank you for pointing this out to me. After some thinking, I decided
> to lump all the defprotocols in one file; having all the APIs in one
> place seemed handy. But using (load) made it possible to keep deftype
> in its own file... though I did have to resort to (use) since (in-ns)
> doesn't support (:use).

You shouldn't need to use (use) or (:use) in the loaded file, because
you can just put it in the (ns) form in the main file.

> src/foo/core.clj ;; (load "core/protocols") ...

e.g. in core.clj:
(ns foo.core
  (:use (clojure.contrib classpath))
(load "protocols")

> src/foo/core/protocols.clj ;; (defprotocol IBar ...)

And then in protocols.clj:
(in-ns foo.core)
(defn blah [] (classpath)) ;; Just use stuff in the "used" library.

> src/foo/core/bar.clj ;; (deftype Bar [] IBar ... )

load is a little like #include in C.  If you specify that the
namespace uses another library in the main file, then you can refer to
that library in the loaded files as long as they're in the same
namespace.  And you tell the loaded file which namespace to create
functions etc. in using in-ns.

-- 
Michael Wood <esiot...@gmail.com>

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