Created
January 2, 2012 18:30
-
-
Save sritchie/1551640 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))) | |
;; Type hinting the inline args throws an exception: | |
;; | |
;; 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