This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-17
Channels
- # admin-announcements (4)
- # aws (26)
- # beginners (88)
- # boot (132)
- # cljs-dev (4)
- # cljsrn (35)
- # clojars (11)
- # clojure (41)
- # clojure-art (33)
- # clojure-austin (1)
- # clojure-chicago (4)
- # clojure-dev (3)
- # clojure-russia (2)
- # clojured (3)
- # clojurescript (9)
- # community-development (19)
- # datomic (34)
- # devcards (2)
- # editors-rus (4)
- # hoplon (29)
- # leiningen (4)
- # music (2)
- # off-topic (21)
- # om (69)
- # other-lisps (1)
- # perun (6)
- # re-frame (1)
- # reagent (9)
- # spacemacs (3)
- # yada (13)
rcanepa: you don't want to do this. What if your database connection failed? Or something else happened? You will never know about it
you can send the exception somewhere (logging/channel etc). "future" is not problem free, but this one is something you can handle yourself
also a good thing to do, especially with core.async, is to use Thread/setDefaultUncaughtExceptionHandler to show/log what is breaking in other threads
Or maybe use a custom threadpool and pass it functions to execute? If you're never going to use the result it seems more appropriate than a future. https://github.com/ztellman/dirigiste https://github.com/TheClimateCorporation/claypoole seem like sensible libraries for custom threadpools. Clojure features page even mentions that Clojure functions are java.util.concurrent.Callable
so you can use them with Java Executors if you don't feel like adding another dependency.
Hi, I have a clojure source file, that I wont to load, change and save. loading and saving is ok with spit and slurp. But how would I change the content. I want to add something to the ns declaration and to a function (so inside existing declarations).
Since it's-just-data maybe something like https://github.com/nathanmarz/specter would be helpful?
@sveri: use zippers for the rescue: https://github.com/xsc/rewrite-clj
@jaen yeah custom threadpool is the way to go. Writting a tiny future fn that takes a pool is a couple of lines.
Curious why clojure.walk/stringify-keys
drops namespaces from keys — is this intentional?
(walk/keywordize-keys (walk/stringify-keys {:example-namespace/example-key 1})) => {:example-key 1}
I expected to get this instead:
(walk/keywordize-keys (stringify-keys-preserving-ns {:example-namespace/example-key 1})) => {:example-namespace/example-key 1}
@jrychter name on keyword does same so maybe it just calls that?
@agile_geek: yes, it does call that. But I'm surprised it doesn't use both namespace and name. This causes obscure problems, because some software expects that the stringify-keys
operation is invertible, which it isn't.
Is my assumption correct that if you read a resource in a repl, from the resources
path, it will be cached and not re-read from disk until you restart the repl?
how would I dispatch different actions based on argument type -> (do-thing :keyword arg1) has a different method body than (do-thing “string” arg1)
you could use protocols for that
@pesterhazy: i think resource lookup is cached, but content itself is not.
@pesterhazy: not even lookup is cached.
I mean, I really just want to write a (url-for {keyword | String} args) thing that knows what to do
@hans, I'll have to try it out. I've encountered problems a couple of times where resources weren't reread until a repl was restarted, or that's what I thought
@pesterhazy: i've seen similar things, but i guess someone with more knowledge needs to answer it. contents itself is surely not cached.
@hans, what did you mean with "lookup is cached", as opposed to "content is cached"?
@pesterhazy: i have experienced similar strange behavior with resources not found when i've added them at run time, but i just tried on the repl and it works well, i.e. i can add a resource that i've previously not seen with io/resource, and after i add it, io/resource sees it.
@pesterhazy: that is what i (wrongly) meant by "lookup is cached".
ah ok
http://stackoverflow.com/a/4750325/239678 <-- this looks like there is some kind of caching
maybe you don't see it in the repl because you're creating a new connection each time