This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-05
Channels
- # aleph (190)
- # bangalore-clj (4)
- # beginners (31)
- # boot (127)
- # braid-chat (2)
- # cider (2)
- # cljs-dev (79)
- # cljsrn (7)
- # clojure (81)
- # clojure-dev (1)
- # clojure-greece (40)
- # clojure-italy (3)
- # clojure-korea (8)
- # clojure-new-zealand (5)
- # clojure-russia (5)
- # clojure-spec (87)
- # clojure-uk (13)
- # clojurescript (50)
- # cloverage (10)
- # component (4)
- # core-async (37)
- # cursive (26)
- # datascript (20)
- # datomic (29)
- # editors (2)
- # emacs (12)
- # hoplon (63)
- # jobs (2)
- # lein-figwheel (1)
- # leiningen (17)
- # liberator (2)
- # off-topic (19)
- # om (31)
- # onyx (9)
- # pedestal (4)
- # proton (1)
- # re-frame (22)
- # reagent (13)
- # ring (1)
- # ring-swagger (9)
- # spacemacs (5)
- # specter (4)
- # untangled (24)
- # vim (29)
Is there a built-in way to explode a val into keyword and value, such that I would be able to insert it into a map? I seem to be repeating myself quite a lot. I want to go from (def x 10)
to :x 10
@singen Why not just (assoc {:a 1} :x x)
? Maybe rethink your data structure? If you need to use x
like that, I'd def
it as (def params {:x 10})
?
But dynamically generating a keyword from symbols is not idiomatic (though possible with macros) and I'd find it unnecessarily confusing code
Relying on the name of local symbols would lead to bugs as soon as somebody renames a local symbol
I have another question! If you are defining a protocol and the implementation is mostly functions (not data), is it proper form to use deftype as the implementation?
You can just use reify
Most uses don't call for deftype
I had to revert back, I couldn’t figure out how to import my functions neatly into namespaces
Hi guys, I have an issue with futures that I just can wrap my head around. Calling future-cancel on a future I have, refuses to set Thread/interupted to true. If im not mistaken this is the expected behaviour?
(future
(try
(do
(while (not (Thread/interrupted))
(println (Thread/interrupted))
(let [tmp-buffer (byte-array 10000)
cnt (.read target-data-line tmp-buffer 0 (alength tmp-buffer))]
(when (> cnt 0)
(s/put! stream tmp-buffer))))
;(.write output-stream tmp-buffer 0 cnt)))
(s/close! stream))
;(.close output-stream))
(catch Exception e (println e))))
this is the future. But Thread/interrupted is perpetually true
future-cancelled? and future-done? both return true
if I understand it properly the reason it has to be in the tail position is that it is optimized into a loop wherein it just changes the values to avoid blowing the stack this means that you can't do anything outside the loop because that would entail keeping that stack frame and its data including stuff left to do after the function itself returns