This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-19
Channels
- # aleph (3)
- # beginners (90)
- # boot (1)
- # cider (1)
- # cljdoc (23)
- # clojars (1)
- # clojure (91)
- # clojure-dev (8)
- # clojure-greece (1)
- # clojure-italy (17)
- # clojure-japan (1)
- # clojure-nl (6)
- # clojure-spec (4)
- # clojure-uk (89)
- # clojurescript (48)
- # core-async (5)
- # cursive (79)
- # datascript (1)
- # datomic (40)
- # duct (1)
- # emacs (7)
- # figwheel-main (2)
- # graphql (7)
- # jobs (5)
- # nyc (5)
- # off-topic (61)
- # other-languages (2)
- # parinfer (6)
- # re-frame (63)
- # reagent (131)
- # ring-swagger (6)
- # shadow-cljs (158)
- # spacemacs (14)
- # tools-deps (15)
is there an anonymous version of multimethod?
something that doesn't coupled with a var
eg (let [my-mm (get-from-somewhere)] (defmethod my-mm ...))
and call it (let [my-mm (get-from-somewhere)] (my-mm ...))
user=> (defn foo [x] (let [mm (doto (clojure.lang.MultiFn. "mm" :x :default #'clojure.core/global-hierarchy) (.addMethod 1 (fn [_] (println "hit"))) (.addMethod :default (fn [_] (println "miss"))))] (mm x)))
#'user/foo
user=> (foo {:x 1})
hit
nil
user=> (foo {:x 2})
miss
nil
`i’m not sure i understand. So you do a http request and get deferred response, and you want to print something before the reponse is realized?
I want to implement an clojure interpreter in c++. And one of these project goals is education. I am a CS student. Where I have to start, and documentation or book ? Thanks already.
@scknkkrer Are you supposed to write the lexer and parser by hand? If not, I would suggest using a parser generator like Bison or ANTLR with the Clojure grammar. ANTLR can generate the lexer and parser in C++
I want to understand the most deeply dark side of clojure or more of that, lisp. I always wonder when they foots seperated from the ground ? When they are starting to fly ? And how much structs I have to implement in compiler side or self-generated language ?
@rahul080327 :face_with_rolling_eyes:
you should read Structure and Interpretation of Computer Programs
In that case I'd suggest writing a LISP interpreter first. Its one of the oldest and most solved problem. Clojure is dialect of LISP and is a bit different from other LISPs. Also if you havent had LISP exposure before try reading https://mitpress.mit.edu/books/structure-and-interpretation-computer-programs
@alexmiller I will. Ok guys. Thanks so much, I think this book will give me a basic understanding about what I want. I will share my project when it is ready. 😊
Good luck @scknkkrer
TIL that (contains? a-set x) is nearly twice as slow as (a-set x). I know it's technically not the same operation but close enough for it to be surprising
I did a quick check on set of size 100 for element in the set with criterium and saw 87 ns for contains and 49 ns for set as function, so not quite twice as slow. Differences are like the var invocation overhead and the boolean coercion.
hitting .invoke directly seems to allow to bypass a number of type check from contains? (and the rest of the chain). Calling .contains on the set is ~ equivalent to invoke
Does anyone know why (diff ['not-shared 'shared] ['shared])
produces [[not-shared shared] [shared] nil]
? I'd expect it to produce [[not-shared] nil [shared]
, going by https://clojuredocs.org/clojure.data/diff
Vectors are compared positionally, you probably want (diff #{'not-shared 'shared} #{'shared})
Ah, thank you very much!
I started to mentor people in clojure and found out that there’s no online code/edn formatter (some links to http://pretty-print.net are dead) Am I missing smth?
Found it, only key value pairs though, which isn't right
what do you guys use for test coverage? i don't know anything other than cloverage
which seems like it needs some work
mainly, it doesn't work in java 10, apparently because it's transitive dynapath
dependency is out of date. the dependency is pulled in by bultitude, whose maintainer died 😕
it looks to me like correcting the dependency in a fork (which already exists: https://github.com/tobias/bultitude, branch: dynapath-0.2.4) would fix the issue, so i'm confused: is nobody using cloverage? or only with java <9, so they don't encounter that issue?
I would guess there is still mostly Java <9 usage out there.
For Clojure users, I don't know if there is much advantage to moving to the latest versions of the JVM, and for reasons like you point out, sometimes disadvantages/pain.
The State of Clojure Survey from early 2018 says this: "Uptake of Java 1.9, released last year, has been a bit slower with only 29% adopting Java 1.9 so far and 88% of developers using Java 1.8. Only 6% of developers are using Java 1.7 and less than 1% are still using Java 1.6." http://blog.cognitect.com/blog/2017/1/31/clojure-2018-results
I would not say nobody is using cloverage, but I would be surprised if it is in widespread use
the last person I recall asking about it is now the second most active commiter on it
Why does loop-recur fail compilation in some cases?
I thought I could recur from anywhere inside loop statement
when it fails to compile, the exception will say something like "can only recur from tail position" which is exactly what the restriction is
(if queue-ns
(recur (update version-streams queue-ns rest)
(conj linearized (get-in ns-defs [queue-ns ::ver-map (get heads queue-ns)])))
(throw (ex-info "Error loading versions" {:type ::linearization ::heads heads ::progress linearized})))
oh that's great formatting
(if queue-ns
(recur (update version-streams queue-ns rest)
(conj linearized (get-in ns-defs [queue-ns ::ver-map (get heads queue-ns)])))
(throw (ex-info "Error loading versions" {:type ::linearization ::heads heads ::progress linearized})))))
that is right
the return
I fixed it now
thanks
https://gist.github.com/hiredman/815406099e7ff4ba676103091b14d70d something similar came up the clojure irc channel a while back
wow, that's awesome
@andy.fingerhut the new standard http client may be a good reason to use java 11
trying to figure out why
(def F "party time")
(defn -main []
(-> "F"
symbol
resolve
deref
println))
throws an NPE on the deref
callthe compiler pushes a value to *ns*
while compiling a namespace, so *ns*
will be foo
while compiling the namespace, then the compiler pops the value of *ns*
so it may be anything while code is actually running
the repl iterleaves compile time and runtime preserving compilation state between calls to the compiler so it behaves kind of differently
so I need to actually in-ns
if I want to do this thing (for nebulous reasons at this point)
in-ns is something you call at the repl to fiddle with compiler state, you shouldn't be calling it in the middle of a function
no, this is a variant I use while debugging
Clojure 1.9.0
(ins)user=> (defmacro locals [] (into {} (map (juxt (comp keyword name) identity)) (keys &env)))
#'user/locals
(ins)user=> (locals)
{}
(ins)user=> (let [a 0 b 1] (locals))
{:a 0, :b 1}
(ins)user=> ((fn [x] (let [a 0 b 1] (locals))) :function-arg)
{:x :function-arg, :a 0, :b 1}
last I checked the compojure router doesn't do reverse routing
this is why bidi
was invented, other routing libs do it too