Created
September 16, 2021 20:09
-
-
Save matthewfl/805d1cf53da0ec0212cc9a229372a6f6 to your computer and use it in GitHub Desktop.
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
(defprotocol my-protocol-1 | |
(my-func-1 [this value])) | |
(deftype my-type-1 [x] | |
my-protocol-1 | |
(my-func-1 [this value] | |
(* value 2))) | |
(def z1 (my-type-1. 123)) | |
(println (my-func-1 z1 99)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defprotocol my-protocol-2 | |
(my-func-2 [this ^long value])) ;; only a type hit has been added | |
(deftype my-type-2 [x] | |
my-protocol-2 | |
(my-func-2 [this value] | |
(* value 2))) | |
(def z2 (my-type-2. 123)) | |
(println (my-func-2 z2 456)) ;; will cause exception | |
;; class user$eval180$fn__181$G__171__188 cannot be cast to class clojure.lang.IFn$OLO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment