How To Refer To A Clojure Record In Another Namespace

May 31, 2015
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.


When to use loop/recur in Clojure?

January 21, 2019
clojure

Clojure Web Frameworks And Comparisons

May 14, 2017
clojure

What Editor/IDE Should You Use For Clojure?

April 22, 2017
clojure