-
-
Save timmc/1551676 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
;; This evaluates properly... | |
(defn barr= | |
([x] true) | |
([^bytes x ^bytes y] | |
(java.util.Arrays/equals x y)) | |
([x y & more] | |
(if (barr= x y) | |
(if (next more) | |
(recur y (first more) (next more)) | |
(barr= y (first more))) | |
false))) | |
;; This evaluates properly the first time, but throws an exception the | |
;; second time: | |
;; | |
;; CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: | |
;; clojure.core/bytes, compiling:(NO_SOURCE_PATH:54) | |
(defn barr= | |
{:inline-arities #{2} | |
:inline (fn [x y] `(let [^bytes x# ~x | |
^bytes y# ~y] | |
(java.util.Arrays/equals x# y#)))} | |
([x] true) | |
([^bytes x ^bytes y] | |
(java.util.Arrays/equals x y)) | |
([x y & more] | |
(if (barr= x y) | |
(if (next more) | |
(recur y (first more) (next more)) | |
(barr= y (first more))) | |
false))) | |
;; Are type hints allowed inline? Why does this work the first time but not the second? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment