So up until now, I've mainly been writing my code in a given file,
using no namespaces, and then just compiling and executing it in a
SLIME-based REPL.

I've accumulated a few functions that seem worth making into a little library.

So, for example, I've written a few permutation functions.  I put
these functions in a file called permutations.clj.  I assume that to
properly get reuse of this library, I need to put in a separate
namespace (or is this not really necessary?).  So, at the top of the
file, I add:

(ns permutations)

Now, when I compile the permutations.clj file in emacs, the REPL can't
use the defined functions unless I prefix them with the namespace:
(permutations/permutations [1 2 3])

It's a bit of a pain that by making a namespace, I've created more
work for myself in terms of using these functions in the REPL.  Is
there a way to make the REPL automatically see these functions?

Next, I want to test whether I can use this library from another file
(in the same directory).  So I create a testperms.clj file.

(ns testperms
  (:use permutations))

This doesn't work at all, so I must have the syntax wrong.

So can someone elaborate, or point me towards a tutorial that explains
how to use namespaces to partition your program into files which can
use functions from other files in the same directory?

Thanks.

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