Fork me on GitHub

Hi. I read clojure-style-guide( and question why author is recommending to use the #_ rather than ;;. I thought ;; is more understandable for code readers. Would anyone know the reason?


As far as I can tell, they only recommend #_ over ; "when you need to comment out a particular form". In that case #_ makes sense because it comments out the the whole form, and as shown in the example, formatting doesn't influence it.

👍 4

@nikoszp Thank you for telling. I didn’t consider a situation as below.

(+ foo #_(bar x
              (baz y)
In this case #_ is clearly better than ;, also in terms of formatting. Thank you.


Am I the only only one annoyed by Paredit? I ended up disabling it and I don't seem to have issues balancing my parens without it. Do most Clojure programmers use it?


@nikoszp I was too in the beginning. But soon enough you will hit nasty syntax errors and paredit / parinfer will help to reduce them. What worked for me was to gradually memorize the shortcuts that I use most. Starting with the "surround with parentheses" one.


@sveri Slurp C-(, C-) and barf C-{, C-} are immensely useful for me


The whole barf/slurp thing annoyed me at first. Now I wouldn't want to be without it and get annoyed if I can't slurp. Got paredit mode enabled pretty much everywhere. I would recommend persisting, it's worth it in the end. Only time I turn it off is if I mess up a cut and paste. Once an unbalanced paren gets in there, paredit doesn't handle getting rid of it very well @nikoszp

👌 8

Thanks for the input guys! I guess learning the hotkeys is a good idea - I just felt a little overwhelmed with all the other emacs hotkeys.


in Cursive I have all the Paredit hotkeys remapped to my liking, and I can't live without it - specially splice and slurp


if you can't remember the hotkeys or if they don't make sense to you, remap! 🙂


never got into Paredit, but I can’t code Clojure without Parinfer now 😄


Yea, cursive with parinfer is my choice too. Learning emacs shortcuts and paredit shortcuts at the same time is a tough task.


I set up some emacs bindings that start with C-c p for paredit commands. Had to define it as a new prefix command, but now I can do C-c p f b for paredit-forward-barf and similar. I actually use the shorter but less memorable keybindings these days, but those long forms are great for casual use.

Drew Verlee14:05:33

When calling clojure from java is it possible to pass functions?


yes, clojure functions are objects implementing IFn


(which is why I tend to get pedantic when people mix up the terms method and function)

Drew Verlee15:05:16

This might be obvious. But when calling clojure from java what is the caller supposed todo with keywords arguments. As far as i understand, keyword isn’t a “type” in java…. core? I mean, would the compiler even recognize the syntax?

Drew Verlee15:05:27

hmm. yes. the answer is to import clojure.lang.Keyword


@drewverlee every clojure data type is reified into a concrete java class FWIW

Drew Verlee15:05:31

yea, that makes sense.


you can use (class <x>) in a clojure repl to get the type of a clojure value <x>


what :kind predicate is appropriate for a PersistentQueue when defining a s/coll-of?

Alex Miller (Clojure team)19:05:42

#(instance clojure.lang.PersistentQueue %)


Oh perfect thanks!


Ah damn, my plan to use queues won't work.. turns out transit cljs doesn't preserve the #queue

Alex Miller (Clojure team)18:05:36

you could write a custom transit handler if you wanted to

Alex Miller (Clojure team)18:05:09

just turn it into a list or vector, then a custom reader to drop the list into a queue on the other side


Hi, I'm using luminus, following the book "Web development with Clojure", and when trying to run a test for a db transcation get an error regarding :id which is a AUTO_INCREMENT key in the h2 database. This is similar to what is found as example in the book. Can you please give me a hand on this?


@lum One problem is that the HugSQL adapter is using jdbc/query to try to run save-assessor! which is an INSERT. Your paste.ofcode doesn't show what get-assessor is doing, but it sounds like you have a bug in that query as well.


@seancorfield The get-assessor query is SELECT * FROM assessores WHERE id = :id.


how can I solve this? Include the :id as the last id of the insertion in the h2 database? If so, would you mind showing how?


hey clojurians, how do you guys use feature flags in your codes ? doing the usual if form ?


@lum I know nothing about HugSQL but the error sounds like you are not passing the correct arguments to get-assessor.


Did you see my comment that your INSERT is not working? So there is no "last id of the insertion".


Is there something built-in or more idiomatic I can use instead of (defn snoop [x] (print x) x)? I just want to print a single value, and return that value.


Perhaps, some core function that: takes a value and a function, applies the value to the function (for side effects), and then returns the value?


Totally forgot that doto was a thing 🙂


@seancorfield I removed the second test of the query refering to get-assessor. Yes, it seems there's some error in the insertion:


SQL: "INSERT INTO assessores\n\t(first_name,\n\tlast_name,\n\temail,\n\tphone,\n\taddress1,\n\taddress2,\n\tpost_code,\n\tpost_code_city,\n\tbirth_date,\n\ttax_number,\n\tto_buy,\n\tto_sell,\n\tto_career,\n\tfirst_message,\n\tis_active)\nVALUES ( ? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? ,\n\t? )" SQLState: "90002" errorCode: 90002 originalMessage: "Method is only allowed for a query. Use execute or executeUpdate instead of executeQuery"


but tried it in a SQL client connected to the h2 database and it worked.


it must be some detail that I can't seem to see.


I can't seem to make this work, what am I doing wrong?

(filter #(nil? (get % :my-key-to-filter)) '({:a 1} {:b 2}... {:my-key-to-filter 3}))


@sjharms Seems to be working to me. Unless your intent is that it return ({:my-key-to-filter 3})


If you want that either replace filter with remove, or on the other hand, replace the predicate with :my-key-to-filter


And if you want to allow nil values under the key, the predicate could be #(contains? % :my-key-to-filter)

👍 4