Last active
August 18, 2016 08:39
-
-
Save kbaribeau/d0d94c02a598490653de to your computer and use it in GitHub Desktop.
Clojure defrecord, namespaces, and dashes vs underscores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user=> (ns my-ns) | |
nil | |
my-ns=> (defrecord Outfit [shirt pants]) | |
my_ns.Outfit | |
my-ns=> (ns clothes.outfit | |
#_=> (:require [my-ns]) | |
#_=> (:import [my_ns Outfit])); note that we defined it in my-ns, but we have to use an underscore to import it | |
nil | |
clothes.outfit=> (Outfit. "t-shirt" "jeans") | |
#my_ns.Outfit{:shirt "t-shirt", :pants "jeans"} | |
clothes.outfit=> (ns clothes.outfit | |
#_=> (:require [my-ns]) | |
#_=> (:import [my-ns Outfit])) ; if we try to import it with a '-', like we defined it, we get a ClassNotFoundException | |
ClassNotFoundException my-ns.Outfit java.net.URLClassLoader$1.run (URLClassLoader.java:366) | |
clothes.outfit=> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ya, this is weird. Why does it do this?