Curious (Clojure) Programmer Simplicity matters

Menu

  • Home
  • Archives
  • Tags
  • About
  • My Talks
  • Weekly Bits & Pieces
  • Clojure Tip of the Day Screencast
  • RSS
November 20, 2017

Clojure Tip of the Day - Episode 3: Threading Macros Tracing

Table of Contents
  • TL;DR
  • Credit

The third episode of my Clojure Tip of the Day screencast is out.

You can find the video on YouTube: Clojure Tip of the Day - Episode 3: Threading macros tracing

The episode shows a quick "debugging" technique using the println function to print intermediate values flowing through the threading macros to the standard output.

TL;DR

  • For thread-first macro you can use (doto println) to quickly print intermediate value

  • Usually, it’s better and more convenient to introduce little helper function *spy* : (def spy #(do (println "DEBUG:" %) %)) which then works for all threading macros

  • If you want to use doto-like method then you need to wrap in an anonymous function: (#(doto % println)) (notice extract parentheses - see macro-expansion of threading macros)

Credit

Thanks to Sean Corfield and Brandom Adams for providing the tips on the Clojurians slack channel.


Tags: screencast clojure-tip-of-the-day clojure

« Clojure Tip of the Day - Episode 4: Threading Macros: part 1 - thread-first, thread-last, thread-as LambdUp Functional Meetup in Prague »

Copyright © 2022 Juraj Martinka

Powered by Cryogen | Free Website Template by Download Website Templates