liveBook · Manning

*print-readably*

As explained in Clojure: The Essential Reference

*print-readably* is a Clojure dynamic variable controlling whether printed representations preserve readable syntax and escape or decorate values accordingly.

*print-readably* is a Clojure dynamic variable that controls whether printed values preserve readable syntax. It governs escapes for characters such as newline and tab, along with decorations such as string quotes. Its default is true. section 23.20

Usually, choose the printing function whose behavior you want:

  • Use pr, pr-str, or related functions for readable output; these set *print-readably* to true. section 23.20
  • Use print, println, or related functions for non-readable display; these set *print-readably* to false. section 23.20
  • Bind the variable directly when calling code whose printing behavior you cannot change. section 23.20

Temporarily disable readable printing

(binding [*print-readably* false] (pr "a\nb\nc")) ;; a ;; b ;; cnil (print "a\nb\nc") ;; a ;; b ;; cnil Both forms display the newline characters across separate lines rather than preserving the escaped string representation.

How Clojure: The Essential Reference covers it

How deep it goes
Defines character escaping and object decoration, but defers broader output controls to related dynamic variables.
Examples
Demonstrates newline output with pr under a false binding and compares it with print.
What you can do after
Apply temporary bindings to alter printing when existing code does not expose a printing-function choice.
How it connects
Relates readable printing to pr, print, println, pr-str, and dynamic variables in clojure.pprint.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.