1

I have a .clj file that starts like this :

(ns clojure_crawl.core)
(require '[clj-http.client :as client])
(use 'clojure.contrib.json)

Followed by several function definitions :

(defn f1 [] "" (+ 1 1))

(defn f2 [] "" (+ 2 2))

etc...

However, when I run the command "(use 'myfile.core :reload)"

Some of my functions , although visible at the REPL, cannot run do to "missing namespace" errors.

How do I add the dependencies so that the REPL can run any of the functions defined in my file ?

2 Answers 2

5

If your code is in "clojure_crawl/core.clj", its namespace should be clojure-crawl.core (note the hyphen). See http://clojure.org/libs

Sign up to request clarification or add additional context in comments.

Comments

3

As Joost already said, you have to be careful with hyphens and underscores: wherever you use a hyphen in your namespace names, replace it with an underscore in the corresponding file/directory names (and vice versa).

Also, the use of the require and use functions in clj source files is discouraged. Instead, declare the libraries you need directly in the ns macro:

(ns clojure-crawl.core
  (:require [clj-http.client :as client])
  (:use clojure.contrib.json))

This also takes the burden of properly quoting the required namespaces from you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.