This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-19
Channels
- # announcements (3)
- # beginners (29)
- # biff (10)
- # calva (33)
- # cider (1)
- # clara (8)
- # clerk (10)
- # clj-kondo (6)
- # cljs-dev (5)
- # clojure (40)
- # clojure-dev (3)
- # clojure-europe (43)
- # clojure-gamedev (1)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-uk (2)
- # clr (3)
- # cursive (12)
- # datomic (4)
- # devcards (3)
- # gratitude (3)
- # honeysql (13)
- # hoplon (25)
- # humbleui (3)
- # hyperfiddle (38)
- # malli (26)
- # pathom (38)
- # practicalli (2)
- # rdf (6)
- # reagent (8)
- # shadow-cljs (13)
- # xtdb (1)
Hello everyone. Why does this return 4?
(apply (symbol "clojure.core" "+") [2 4])
Because what you have is ('some-symbol 2 4)
which is the same as (get 'some-symbol 2 4) (get 2 'some-symbol 4)
and that's the not-exists arity so (get 'some-symbol 2) (get 2 'some-symbol)
would return nil
, and (get 'some-symbol 2 4) (get 2 'some-symbol 4)
will return 4
. [Thanks to @U7RJTCH6J for the correction later in this thread!]
A symbol != its value.
I see
(apply (resolve (symbol "clojure.core" "+")) [2 4])
is what you want
That resolves the symbol 'clojure.core/+
to the value it is bound to, the function clojure.core/+
(and if you're new to Clojure, this is a good question for #C053AK3F9 where folks are generally a lot more patient than in #C03S1KBA2 🙂 )
Symbols don't actually have values, they are just sort of loose identifiers, they will map to different values depending what you look them up in
Thanks, not new to clojure, but trying to overload the plus function in macroland, and got confused about what was happening
(I edited my comment to say "the value it is bound to" instead of "its value" -- if you resolve
a symbol that doesn't have a root binding to a value, you get nil
)
Since we're being more pedantic 🙂
> Because what you have is ('some-symbol 2 4)
which is the same as (get 'some-symbol 2 4)
While we're being pedantic, ('some-symbol 2 4)
is actually the same (get 2 'some-symbol 4)
Thank you for catching that... yes!
ditto, very interesting, actually
Thank you all
out of curiosity, has anyone here ever intentionally taken advantage of symbols implementing IFn
? I don't think I've ever done it, or even seen it
Handy tip for VisualVM users. It is sometimes difficult to tell which of these is my repl. Don't fret, write
(.pid (java.lang.ProcessHandle/current))
=> 735515
and have a good day 
and if you use cider with emacs, their is a command to take you to the repl for the buffer your are currently in.
I got lazy and wrote something to launch visual vm from inside the java process 🙃
for this I always add to my deps.edn (as soon I create it) a :jvm-opts ["-Dproject-name=MyFancyProject"]
and then I can see it in VisualVm on the first tab
Is there an open source code coverage tool that doesn’t require lein
like cloverage does? All I see are cloverage and a commercial option.
there is a plugin for kaocha - https://github.com/lambdaisland/kaocha-cloverage
I’m pretty sure you can use cloverage from kaocha Edit: As @U04V4KLKC already mentioned and linked 🙂
Oh nice!
you need to run cloverage.coverage
and pass the args as opts map, it works just not most documented
clj -Sdeps '{:deps {cloverage {:mvn/version "RELEASE"}}}' -m cloverage.coverage *args-to-coverage*
Here’s my GitHub action for deps cloverage
https://github.com/mentat-collective/emmy/blob/main/.github/workflows/coverage.yml
That’s excellent. Very helpful
I’m surprised there aren’t any articles out there on this, but there are plenty for the lein approach from years ago.
Yeah, I find coverage to be really helpful, especially with GitHub’s highlighting of covered and not-covered lines
What's the commercial option @U061KMSM7?
Maybe? I just discovered it today
I think they write about uploading coverage reports after creating them with cloverage. Seems to be dependent on cloverage or similar tools, rather than a replacement?