Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I define something belonging to another namespace in clojure?

Tags:

clojure

I have a clj file using a certain namespace and I wish to define something belonging to another namespace, so I do :

(def  other.namespace/name-of-something "value")

: but when I do this I get the result :

java.lang.Exception: Can't refer to qualified var that doesn't exist

Does anyone know why?

like image 937
yazz.com Avatar asked Jan 04 '11 22:01

yazz.com


1 Answers

First, you'll need to ensure that the namespace exists via a call to create-ns:

(create-ns 'other.namespace)

Then, you can use the intern function to add definitions to that namespace:

(intern 'other.namespace 'name-of-something "value")

You can confirm this is present with a call to (ns-interns 'other.namespace).

like image 183
Tim Clemons Avatar answered Oct 21 '22 13:10

Tim Clemons