Fork me on GitHub

@jswart: Thanks, that really helps!


I am doing an AWS lambda clojurescript function. I have some external .edn files I want to read and def as a map in my code. (slurp “ “) doesn’t seem to work in clojurescript — what is the normal protocol for such?


@fingertoe if those files are resolved at compile time you can do it via JVM clojure using a macro


@bwstearns hey thanks for reply. that's just a self contained example which captures the essence of what I'm trying to achieve. real code is not like that! 🙂


Hi, people! what's up with the odd issues with type conversions in clojure? If I write a function like this:

(defn ^long foo [] 6676046666777281638)
and then try to convert the result to double:
(double foo)
clojure doesn't like it, and spits out this:
CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: [email protected]
What's going on here? NOTE: it does not depend on the dimension of the number, - whether I write 65012734070871023874 or 5 I get the same result


and, the funny part comes when I try to convert it to long - it doesn't work either, spitting out the same error!


I don’t know this area very well, but

user=> (defn ^Long foo [] 6676046666777281638)
user=> (double (foo))


foo isn’t a number ,it’s a fn


@donaldball sorry, I meant (double (foo)) @st sadly, changing the "foo" function is not an option - it belongs to a library


by the way, after some fiddling, I found the answer:

(double ^Long (foo))
no idea why the author of the library used (defn ^long ...) instead of (defn ^Long ...) though.


the first example is not correct use of a type hint - var meta are evaluated so the long will actually resolve to the clojure.core/long function which is the result of the error


you can see that if you (:tag (meta #’foo))


(defn foo ^long [] 6676046666777281638) is what you want


in this case the type hint is handled by the defn macro, which will not evaluate it


if you really want it on the var you can do (defn ^{:tag 'long} foo [] 1)


hinting it as ^Long is probably not what you actually want - that’s the Long wrapper object and will not give you the primitive return type performance that you likely want