Fork me on GitHub

I have a java object that's being created by a factory class, so I'm not directly instantiating it. I'd like to add some state to the object, just a simple integer field, and maybe getter/setter for this field. I can proxy or gen-class a new type, but is there any way I can actually add state and methods, given that I do not directly create the object?


Hello, which libraries are used to do database work? I found java.jdbc package, is there any widely-adopted layer above it? Just trying to figure out what's the standard approach.


@sgdread Many options. One of the latest offerings is toucan.


is there a cleaner way of writing:

(doseq [[x y] (map vector xs ys)]
it seems like there ought to be a shorter way of writing this


@qqq (map (fn [x y] ...) xs ys)?


well, map is lazy right while doseq is not right? so I'm running a number of assertions


so I think doseq would exec the assertions wheras map would create a lazy list which does not exec the assertions until they are needed


you can wrap it in doall


wrap it in a doall


hmm, clever


but I’m not sure if it’s more readable than you initial expression


while clever ppl are here, is there a hsorthand for (every? identity ...)? it's basically (apply and ...) but I can't do the latter becaseua nd is a macro not a function


@residentsummer it does work better because (did not put this in original question), the (fn [ x y] ... ) is an existing function which has a simple name, so it ends up being (map foo xs ys)


qqq: looks like (every? identity …) is the best option...


I wonder why every? does not have unary variant though


pull request 🙂


hey guys. Im studying the source of clojure.core


as to the definition of if-not


why not just


how can I run a REPL session in my code directly? Say, I have a (try-catch) block and I'd like to run REPL in catch clause in my current ns. Thanks.


You can start a repl server using functions in


I'd like to have the following:

(try (call-my-func) (catch Throwable _ (repl/start)))


when repl/start is called, a new interactive REPL session is started, so I can check the exception content. Then I interrupt it and the programm continue to execute.


you know, like in Python we do import pdb; pdb.set_trace()


unfortunately I don't think it's possible to do it to the extent python does. the JVM optimizes away a lot of things (like locals), so I don't think it's possible to just fire up a repl in the context of where an exception is thrown.


@qqq so in your example earlier, mapping vector -- you said that you are running assertions, presumably to ensure that the resulting data is valid. But where are you performing the assertions?


joshjones: in the ... of the (doseq [[k v] (map vector ks vs)] ... )


ah, so in the doseq block itself -- but then you don't get to hold on to your result, but i guess that's stuff you've already worked out


right, the doseq isn't about generating values, it's about running assertions


I’m attempting to integrate a servlet (from Auth0) into a clojure app. It requires context-params be set in web.xml Does anyone have any pointers here to make it work? I’m following this guide:


Looks like they have a java library which I could use instead.


But if anyone has any pointers for the above problem, please reply


what is the problem you're running into?


can you write a spec for a protocol? something like:

(defprotocol Foo []
  (s/fdef bar ...)
  (bar [this x] ...))


Hello everyone. Just wanted to say hello! Just starting my clojure journey. Very excited, and looking forward to meeting some of you.


@U46T0D7ED same. I've been listening to a lot of talks by Rich Hickey. I keep hearing more good things about the language.


@U46LM0HR6 Seriously. I know i have a decent learning curve ahead of me, but i feel like the end will justify the means. It just seems so rich in possibilities and how it can do a lot in less code just blows my mind.


For what it's worth, the learning curve for Clojure is a lot smaller compared to several other languages. That's been my personal experience at least.


That's interesting to hear, @U08PR8LJZ. What was your language background prior to Clojure?


@U050CT4HR I actually consult. So I've written code in several languages.. Ruby, Java, Clojure, Scala, C# ... To name a few. Clojure was the simplest for me to wrap my head around. The biggest obstacle was getting used to functional programming. But once you figure that out, things fall into place


Right on.


I'm curious, did you have any editor woes when you were first getting started? I know that can be an obstacle for new Clojurians.


@U050CT4HR yup! Luckily though, you can find a nice groove in a few different editors once you've established the plugins. I prefer vim. With a few different plugins added to it for Clojure specifically. I've been testing out Atom more recently and I like that as well. I hear good things about Cursive, but there is a price tag with that.


@U08PR8LJZ thanks. I kinda feel like since i don't have a ton of previous programming experience it won't be as hard as say, having years of experience, and then learning clojure. Not sure if this is true though haha.


I used to be a TA for Northeastern University's introductory computer science course which was taught in a dialect of Scheme. Our experience was that students who did and did not have prior programming experience faced different challenges, though it was hard to say which whose challenges were greater.


Either way, I'm sure you'll be fine! I'm excited for you!