What do clojure namespaces look like?

For starters, I'm not a Java programmer, so it would be helpful if your answers were not defined in terms of Java (as that makes sense).

I have a leiningen project (specifically a web project using noir ), using what seems to be a general layout of clojure source files in src/YOUR-NAMESPACE/ . So far, I managed to add directories and files, and I used the file path as the basis for ns (following the pattern that I see in the generated code).

I added a new file that did not work, and I wonder why. Its path is PROJECT-ROOT/src/bayou/lib/api-helpers.clj and its namespace (ns bayou.lib.api-helpers) . The specific error I get is:

java.io.FileNotFoundException: Could not locate bayou/lib/api_helpers__init.class or bayou/lib/api_helpers.clj on classpath

What are all the steps you need to take to clojure recognize a namespace?

+8
classpath clojure leiningen noir
source share
1 answer

The problem is the hyphen in the namespace.

Out of Joy Clojure

HYPHENS / UNDERSCORES If you decide to name your namespaces with hyphens, a la-my-cool-lib, then the corresponding source file should be with underscores instead of hyphens (my_cool_lib.clj).

Here is an explanation: https://stackoverflow.com/q/4451693/32174

+12
source share

All Articles