Personally, I don't load individual .clj file at the command line.
I'll usually build a .jar & include it in my classpath.

On Feb 5, 5:52 pm, Mike Jarmy <mja...@gmail.com> wrote:
> OK, here's a slightly more elaborate toy example that works.  In this
> example, foo-main.clj needs foo-a.clj, and they both need
> foo-util.clj.  I was expecting the (in-ns) call in foo-a to have a
> ":load" keyword, just like (ns) in foo-main, but it doesn't, so I just
> called (load) afterwards.
>
> Anyway, this will work for me.  If there is a more idiomatic way to do
> it, let me know.
>
> It might be helpful if the documentation 
> athttp://clojure.org/namespacesmentioned how to split out a namespace
> into multiple files.  It mentions (in-ns) in regards to REPL, but for
> scripting it doesn't really explain how multi-file namespaces are
> supposed to work.
>
> ;; foo-main.clj
> (ns foo (:load "foo-a" "foo-util"))
>
> (defn main []
>   (print "hello from main\n")
>   (aaa "FOO-MAIN")
>   (util "FOO-MAIN"))
>
> (main)
>
> ;; foo-a.clj
> (in-ns 'foo)
> (load "foo-util")
>
> (defn aaa [arg]
>   (print (format "hello from aaa: %s\n" arg))
>   (util "FOO-A"))
>
> ;; foo-util.clj
> (in-ns 'foo)
>
> (defn util [arg]
>   (print (format "hello from util: %s\n" arg)))
>
>
>
> On Fri, Feb 5, 2010 at 5:26 PM, Mike Jarmy <mja...@gmail.com> wrote:
> > Greg: your code works, if I go back to the original classpath.
> > Thanks.  The 2nd classpath I posted was purely out of desperation, I
> > didn't think it was really going to work.
>
> > What your code implies to me is that for each namespace, there should
> > be one source file that is sort of the 'master' file -- foo.clj in the
> > case of my toy example.  The other files in the namespace should use
> > (in-ns).  I'm going to experiment now with loading one of these
> > subsidary files from another.  Maybe the lesson will be that you
> > aren't supposed to do that, we'll see.
>
> > I wouldn't say that closure's documentation is barren per se.  I've
> > got "Programming in Clojure" and
> >http://java.ociweb.com/mark/clojure/article.html, which are both
> > helping a lot (plus clojure.org of course).  Clojure is still pretty
> > new, I'm sure the documentation will improve.  I would say that the
> > documentation does a good job on the lispy parts of clojure, but not
> > so good of a job explaining namespaces, code organization, etc.
>
> > On Fri, Feb 5, 2010 at 5:09 PM, Greg <g...@kinostudios.com> wrote:
> >> Mike, I'd say this is not your fault. I'm a clojure newbie too and the 
> >> answer to your question is nowhere to be found in Clojure's barren 
> >> documentation.
>
> >> You're using the right command line stuff, but you need to change your 
> >> code:
>
> >> ;; foo.clj
> >> (ns foo (:load "foo-util"))
>
> >> (defn main []
> >>  (print "hello from main\n")
> >>  (frob))
>
> >> (main)
>
> >> ;; foo-util.clj
> >> (in-ns 'foo)
>
> >> (defn frob []
> >>  (print "hello from frob\n"))
>
> >> - Greg
>
> >> On Feb 5, 2010, at 4:38 PM, Mike Jarmy wrote:
>
> >>> That yields ".;lib/clojure.jar", just as we'd expect.  I also tried,
> >>> "java -cp foo.clj;foo-util.clj;lib/clojure.jar clojure.main foo.clj",
> >>> but that gave the same error.  All of these classpaths work when I
> >>> comment out the calls to "(require 'foo-util)" and "(frob)" -- which
> >>> you would expect, since at that point foo.clj is just a trivial hello
> >>> world script.
>
> >>> So we are agreed that my clojure code *ought* to work, given the
> >>> correct class path, but it does not?  So this must be some clojure
> >>> classloader thing?  Maybe I'm doing something out of the ordinary
> >>> here, and there's a more closure-idiomatic way to do it?  It does seem
> >>> like the right approach to me that every file in a given directory
> >>> should have the same namespace.
>
> >>> On Fri, Feb 5, 2010 at 4:16 PM, Meikel Brandmeyer <m...@kotka.de> wrote:
> >>>> Hi,
>
> >>>> Am 05.02.2010 um 22:13 schrieb Sean Devlin:
>
> >>>>> This expression will provide a string that is the classpath
>
> >>>>> ((into {} (System/getProperties)) "java.class.path")
>
> >>>>> There's probably a more elegant way...  anyone?
>
> >>>> Simply (System/getProperty "java.class.path")?
>
> >>>> Sincerely
> >>>> Meikel
>
> >>>> --
> >>>> 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
>
> >>> --
> >>> 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
>
> >> --
> >> 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

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