This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-20
Channels
- # ai (1)
- # beginners (17)
- # boot (27)
- # cider (2)
- # cljs-dev (64)
- # clojure (131)
- # clojure-austin (13)
- # clojure-dev (15)
- # clojure-dusseldorf (11)
- # clojure-france (45)
- # clojure-russia (19)
- # clojure-spec (66)
- # clojure-uk (22)
- # clojurescript (97)
- # core-logic (7)
- # cursive (5)
- # data-science (1)
- # datomic (92)
- # dirac (49)
- # emacs (1)
- # events (5)
- # funcool (10)
- # hoplon (79)
- # jobs (1)
- # jobs-rus (1)
- # lein-figwheel (1)
- # leiningen (3)
- # om (14)
- # onyx (35)
- # planck (2)
- # proton (1)
- # re-frame (21)
- # reagent (2)
- # ring-swagger (10)
- # spacemacs (10)
- # specter (18)
- # untangled (7)
- # vim (23)
@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: clojure.core$long@77d55649
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 resultand, 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/foo
user=> (double (foo))
6.6760466667772815E18
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