How To Refer To A Clojure Record In Another Namespace

clojure

I ran into an issue like usual. This time it seemed simple. I wanted to refer to a record that I def'd in another namespace.

The problem is, you can't just do a :require and :refer it in regular Clojure. However, in Clojurescript this is how you would do it.

What you have to do is :import it. And the key trick to keep in mind when using :import on records and Clojure namespaces is that dashes are converted to underscores like packages in Java.

If you had a namespace like (ns foo-bar) in which there was a record called MyRecord, you would do something like this:

(:import [foo_bar MyRecord])

And you'll be off to the races.