Skip to content

Instantly share code, notes, and snippets.

@luxbock
Created September 24, 2014 18:43
Show Gist options
  • Select an option

  • Save luxbock/e0a6246d01f5689b5524 to your computer and use it in GitHub Desktop.

Select an option

Save luxbock/e0a6246d01f5689b5524 to your computer and use it in GitHub Desktop.
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