Fork me on GitHub

is it possible to do something like:

`(do (def some-var {:some :vals}) (~another-fn ~some-var))
and have ~some-var evaluate to {:some :vals}?


anyone: can I use [a & {:keys [x y z] :or {x 1 y 2 z 3}] notation in protocol functions and with extend-protocol?


but when calling the function it won't allow me to leave the :x :y and :z unspecified




it works when I call (f a :x blah :y blah :z blah)


Looked on clojuredocs and stackoverflow, but didn't find any helpful examples


varargs not supported on protocols


hi guys does any one have problem with bouncy castle when running the app as a jar ( test works fine ) java -jar app.jar I got this stacktrace:

Caused by: org.bouncycastle.openssl.PEMException: Unable to create OpenSSL PBDKF: PBKDF-OpenSSL SecretKeyFactory not available  
Caused by: PBKDF-OpenSSL SecretKeyFactory not available   


@nxqd: there are a bunch of results in Google, have you been able to try any?


@danielcompton: yes I have tried to download the jce unlimited and try out to put vendor configuration on but none of those works.


<@U051KLSJF>: I've found the solution -_- after sleeping on it for a while, I remember github is the best source to find code solution now. For those who don't know : <>


Agreed, I often look for examples on github using its search feature simple_smile


With Clojure, that was intentional, and Cognitect (formerly Relevance) played a major role. The community was built with practicality as a core value. It had the opportunity to learn from the failures of Common Lisp (both as a language and as a community).


What did clojure's community learn from that of common lisp and do better?


To me, it is almost obvious that clojure is better than common lisp as a language, but the community thing is unclear to me.


Slightly off topic but need recommendations for a good book to learn Java. Something modern/new and not for first time programmers. The only decent recommendation I've gotten so far is Thinking in Java (4ed) which was released quite a long back.


@crocket: could it have something to do with this?


disclaimer: I'm not familiar with the CL community, only with the stereotypes


I was there when the SmugLispWeenies page was created (I think ...) and i wouldn't say it was all about CL. There were a lot of smug scheme weenies too (and a lot of friction caused by the conflation of the two communities)


the reason I jumped ship from CL (apart from the bit about needing to get paid) was in the end not only that it was painfully awful to do stuff outside of the standard but that so many people seemed to have a vested interest in pretending otherwise


but it would also be wrong to regard the "cl community" as homogenous, at least in the (< 2000 year 2008) period I was a part of it


CL library developers are somewhat notorious for making a thing to MVP for their purposes, and then if they make it available at all, as a lump archive with no continued support or development to be expected.


Clojure has its flaws, but I find at least that the community is more likely to develop "in the open" on average.


Is core.match still being maintained?


crocket: Well mostly, and I say this in full acknowledgement of my own guilt, I do find myself frustrated with Clojure documentation culture often. 😉


I thought you were talking about community flaws.


@jarcane: I'm also frustrated by how things are generally unfinished or not polished enough. But it's up to us change that.


crocket: I would consider documentation culture a community issue. Software is made by and for people. simple_smile


I was thinking about abuse toward others.


(this is why I am also something of a hypocrite here, because I am very, very prone to CL-style "works for me" development)


Fork a lib with bad documentation/maintaning and do it better.


crocket: Ahh, no, I have not encountered much of any of that, thankfully.


thiagofm: I have in some cases. 😉


#C099W16KZ IRC channels are unfortunately infested by some trolls, by the way. This channel is not.


I still work with ruby daily and it's immensurable how bad clojure is when compared to ruby in that side.


You can almost find all the possible problems on stackoverflow. Big libraries are well documented. Only frameworks with good documentation survive and so on.


I suspect that's more due to time and number of practitioners.


I have a lot of pleasure working with the language, but the ecosystem kind of sucks.


I’m having a weird thing with Aleph’s http client. When making the request with curl it works just fine but when using aleph.http/get the deref just blocks forever. Requests to other than this one resource work, but then again resource works fine with curl.


I definitely saw a improvement in the past years in clojure, in that sense though.


@thiagofm: I agree with you to some degree. But, there is a thing that compensates this for me. I think clojure code is most of the times easy to understand. Also the scope of the libraries is kept small mostly. That makes me browse the source code more often than in any other language I have used and I can understand it quiet often and answer the questions myself simple_smile


@sveri: same here but that still is a major hurdle for people just getting started. Also reading a libs code requires some confidence not all beginners have from the start.


I'm mildly surprised to see that ruby docs are being held up as an example of how to do it right


I know that doto is intended for interop, but I think that it’s really useful when I want to generate a side-effect and return the previous value, such as:

(doto (compute-val x)
(let [val (compute-val x)]
  (gen-side-effect! val)
You guys think this is a code smell?


I think it's fine.


Someone not familiar with doto might be confused what’s being returned, I’d probably decide based on how important it is to optimize beginner-friendliness.


But then again they’d learn about doto this way so I guess it goes either way simple_smile


By the way, re earlier discussion of docs, accepts contributions — feature guides wanted in particular


Documentation for Clojure itself is already quite good, both with the official site and with free resources like the Brave and True book. The READMEs of many popular libraries are way below par though. (and yes I do intend to submit some PRs to improve that)


there are also counterexamples, there's tons of great stuff in the Luminus docs for example


@plexus: you have some examples in mind right now for popular but under-documented?


Friend and Enlive took me pretty much a day of studying the source each


but yeah, not blaming anyone. Technical writing is really its own skill, and it's not easy to do well


Yes, friend has poor documentation. I found all the auth libs tone very poorly documented


Auth* is a hard problem to generalize.


yeah I looked at buddy as well and was like, "I have not the slightest clue from which angle to approach this thing, I'll just go with Friend"


I struggled with OAuth in friend for days. And I find buddy incomprehensible


although I'm using buddy/hashers now together with friend ¯\_(ツ)_/¯


I'm using friend. Despite its poor docs, it was more approachable than the other so called 'better' auth libs


I've used friend a couple of times, I think the single biggest doc change it could make would be a para saying "if this doc does not answer your questions, feel free to look at the source code - it does not bite"


but the number of ruby libs I've used where the documentation is a README and then a set of entirely unhelpful rdoc files and then you click on 'view method source' and the method is a one-liner that calls some other internal method and then you click 'view on github' and get a 404 because it's moved


and that's before you even start worrying about whether the version of the library you're running is the same one as the documentation (which you found by googling) is written for


I'm told that python does it a lot better. I tend to believe that no matter what ecosystem you're in it looks from the outside like everybody else does it better


see also description of 'documentation which describes only the differences'


I have a "Cyclic load dependency" problem. I have a db namespace that needs to put things on a job queue and a job queue ns that needs to do the work and write back to the database. Can’t figure out how to break the cycle. Any ideas?


it sounds like your db namespace is doing other things than writing to the db. for intsance, it enqueues things


@juliobarros: I have a similar issue (one ns reads data from hardware, another ns serves it over the web). I would put functions that interact with the db in the db namespace (taking and putting), and the queue ns just calls the relevant functions in db? Would that work?


make things just directly talk to the queue ns and let that delegate how it gets to the db ns?


Split the work: db API functions in the db ns, queue API functions in the queue ns, work that involves both in its own ns.


@dpsutton … yeah 😄 but I need to write to the DB and enqueue when something changes. Didn’t want to make every other NS that needs to save also “know” that it needs to enqueue.


do what stuart said. Make a single ns that people call. inside of there its smart enough to know when just put in db, db and queue, or just queue


then your caller's only need a single interaction ns


"work that involves both" often goes by the name 'controller', I find it helpful to think of the structure of e.g. Rails or Play apps when doing Clojure


I've had exactly this problem in some web application where I tried to do too much in one namespace that represented some domain (and had a dependency on some other domain which in turn needed a dependency in the other direction)


Thanks all. Let me think this through. I hear what you are saying but am not sure how to best apply it to what I want to do.


@rohitarondekar check out Big Java


@risto: Thanks. Which one did you mean? There is a early objects and late objects version. The book website doesn't seem to have any info on the target audience


though it seems like early and late objects is his latest editions, late objects being the next logical step to read


The book i referenced is for beginners. It doesn't cover all of the advanced topics


@risto: ok thanks I'll take look simple_smile


For example, when a piece matches a

the next piece need to be added as a new key
for all waypoints until the next match


I’ll try to ask again...


I’m working with zippers and xml, and for some reason code like this returns the empty list:


(def xml "<foo id = \"qix\">bar</foo>")
(def z (-> xml parse-str xml-zip))
(xml-> z


This seems strange to me as


(xml-> z
       (attr= :id "qix")


works, as in it returns (bar) as expected


ah, it seems to be an issue on this already:

Alex Miller (Clojure team)20:04:13

I actually looked at this for a bit a couple months ago

Alex Miller (Clojure team)20:04:27

but ran out of timebox before I understood why


it only fails if you try to match on the first element.


commented on the issue


I keep needing to apply a fn to a val if the fn is defined, otherwise return the val. Is there an idiomatic way to do that? Something like

(defn apply-if [f value]
  (if f
    (f value)


also, I was using instead of clojure.xml/parse


kirked: are you sure you don't want fnil?


apply-if is not exactly fnil but I suspect whatever you are doing with it, if you think about it slightly differently, you can use fnil instead


I think in my case the default value would always be identity


I could use fnil, but I was thinking perhaps there's a standard function somewhere whose name I don't know that essentially does the above.


for example, if you where counting things (reduce (fn [counts thing] (update-in counts [thing] (fnil inc 0))) {} seq-of-things)


My use case is doing configuration-driven transforms on Google Analytics query results for a graphing library. So in some cases the transform will be defined, in other cases it won't be (based upon the form needed to supply the graphing library).


((fnil apply identity) (get config :fn) [arg])


I can see how that works. But if I have to write my own code to apply a function if it's defined, I think the if-based one reads easier. I was hoping for something in core that I couldn't find.


I would recommend making apply-if take multiple arguments instead of just one, like apply does, although figuring out what the return value should be in the else then would be kind of tricky


(defn apply-if [f & values] (if f (apply f values) (first values))) or something


so your apply-if is more closely matched with apply


the else case is kind of blah though


obviously you should do it with spectre, and define a spectre navigator that only visits things you have defined transforms for 😛


kirked: I don't understand what you mean by " if I have to write my own code to apply a function if it's defined" - apply is part of clojure, and the fnil apply thing works as is


user=> ((fnil apply list) (get {:f + :g -} :f) [1 2 3])
user=> ((fnil apply list) (get {:f + :g -} :h) [1 2 3])
(1 2 3)


well, you do have to write (fnil apply identity) everywhere you would want to use it, so you meant want to (def apply-if (fnil apply identity)) but once you do that, you might as well optimize for understanability over brevity, which, well, I think most people would comprehend the if version faster


@noisesmith: I meant "if there's not a function in core that already does this"


nb. to me fnil is a standard tool like comp or map that doesn't need to be hidden by an abstraction


it has simple semantics, and is useful precisely because it is weaker and easier to understand than if


(just as reduce is useful because it is weaker than loop)


if you’re using get to extract the transform fn, you can always (get config :fn identity)


good point, and identity is a bad fallback because there might be more than one arg in the collection (which is why I used list instead)


hello folks, a question: is timbre going to replace println out of the box?


ok maybe i forgot some conf...