What little clojure tricks did you not realize for years?

comment-next-form stacks – Alex Miller

Nesting thread macros – Dustin Getz and davedrowsy

doto is not just for interop – Technomancy, davedrowsy

some-> for interop – joinr

joinr: Using some-> for interop (kind of like doto or ..) is really useful since many operations return null, and if you want to do some deeply-nested effectful interop stuff, you can short-circuit without writing a bunch of conditions. I picked up on this from the NightCode source, and have adopted it...


jwhitlark: Having a user.clj at the root of source, set up for debugging and only included in dev code, to speed up testing/debugging/exploring/experimenting. That way, just opening a REPL has all the tools and aliases already set up.

deep-def – jeremyrsellars

jeremyrsellars: In REPL-based development, it can be useful to def deep inside a fn or other form to capture the last value. Then, when some other code evaluates your awesome function, the part of interest is captured as an object, not just dumped to the screen as in prn. I first learned this from Alex Miller at the KCDC.

tap> (coming in Clojure 1.10)

lgstein: So if in a REPL/PREPL or program a "tap>" happens, all PREPLs connected to that environment are notified.
Alex Miller: Well it can be used in a debugging context to "log" values onto the tap and "read" those values from the tap anywhere. So if you added a tap> in your code, and you have a repl in the process you can add-tap to start siphoning out those values and print, log, save to a file, whatever. It's special in that prepl knows about it and can tunnel them to a remote repl too.

java interop workarounds – joinr

Load a template resource at compile time from CLJC – Karl Hardenstine

Destructure seqs that can contain errors – d_t_w

set predicates inside filter – d_t_w