Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
data-readers weirdness
(deftype Bar [a]
Object
(equals [self other] true)
(toString [_] (str a)))
(defn barme [a] (->Bar a))
(set! *data-readers* {'bar myns/barme})
;; #bar :foo => nil
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftype Bar [a]
Object
(equals [self other] false)
(toString [_] (str a)))
;; #bar :foo => #<Bar :foo>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftype Bar [a]
Object
(equals [self other] (= self other))
(toString [_] (str a)))
;; #bar :foo
;; => CompilerException java.lang.StackOverflowError, compiling:(/private/var/folders/j2/zvt92c1s39d_0kdmhrhbgtkm0000gn/T/form-init1859776228210896770.clj:1:5200)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftype Bar [a]
Object
(equals [self other] (= (.a self) (.a other)))
(toString [_] (str a)))
;; #bar :foo
;; => CompilerException java.lang.IllegalArgumentException: No matching field found: a for class clojure.lang.Symbol, compiling:(/private/var/folders/j2/zvt92c1s39d_0kdmhrhbgtkm0000gn/T/form-init1859776228210896770.clj:1:5200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.