On Mar 25, 7:04 pm, Parth Malwankar <parth.malwan...@gmail.com> wrote:
> Hello,
>
> I am trying to organise my code in namespaces and needed a
> little help.
>
> Basically I have created the following namespaces similar to
> the following:
>
> src/org/ppm/foo.clj -> org.ppm.foo
> src/org/ppm/foo/
> src/org/ppm/foo/bar.clj -> org.ppm.foo.bar
> src/org/ppm/foo/baz.clj -> org.ppm.foo.baz
>
> foo.clj is an empty file which does nothing but
> combines bar and baz:
>
> == foo.clj ==
> (ns org.ppm.foo
>   (:use [org.ppm.foo bar baz]))
>
> After having the jar in classpath, I create a simple
> test.clj script that I load.
>
> == test.clj ==
> (use 'org.ppm.foo)
> (bar-func)
> (baz-func)
>
> At this point, test.clj does not see the functions
> defined in bar and baz.
> Doing a (in-ns 'org.ppm.foo) before function calls
> makes it work fine.
>
> Is there a way to have foo.clj selectively (or all) expose
> functions from bar and baz to the end user via foo namespace?
>
> Do I need to put all exposed functions into foo.clj? I would
> prefer to keep them in bar and baz if possible as those
> are logical blocks for me.

Sorry for replying to my own post.

I think I figured out one way of meeting my needs.
I have split up the foo namespace across multiple files. So,
I have the following now:

src/org/ppm/foo.clj -> org.ppm.foo
src/org/ppm/bar.clj -> org.ppm.foo
src/org/ppm/baz.clj -> org.ppm.foo

With foo.clj using the ns :load for loading bar and baz.

(ns org.ppm.foo
  (:load "bar" "baz"))

This meets my needs well as the code is split in
logical units while exposing the same namespace
to the end user.

Parth

>
> Thanks.
> Parth
--~--~---------~--~----~------------~-------~--~----~
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
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