concept print in category clojure

appears as: print, prints
Clojure: The Essential Reference

This is an excerpt from Manning's book Clojure: The Essential Reference.

var = 100
if var = 200:
   print "1 - Got a true expression value"
elif var = 150:
   print "2 - Got a true expression value"
elif var = 100:
   print "3 - Got a true expression value"
else:
   print "4 - Got a false expression value"

18.2  pr, prn, pr-str, prn-str, print, println, print-str, println-str

Clojure has a rich set of printing functions and this section of the book presents those declared in the clojure.core namespace. Functions starting with the full prefix "print" (print, println, print-str and println-str) produce output optimized for human consumption. Those starting with "pr" only (pr, prn, pr-str, prn-str) produce a slightly different output which is designed to be readable back by read-string, enabling basic Clojure serialization footnote:[Serialization is a mechanism for persisting arbitrarily nested data structures or objects (in case of Java) to disk or network. The name derives from the fact that what appears normally as a graph of data in memory is flattened to a single row of bytes to be sent on the wire. The graph is then restored once the bytes are de-serialized back into their original shape.).

The following example shows the typical difference between pr and print (and related functions of the same group):

(require '[clojure.pprint :as pretty])

(doc pretty/write) ; #1
;; -------------------------
;; clojure.pprint/write
;; ([object & kw-args])
;; Write an object subject to the current bindings of the printer control variables.
;; Use the kw-args argument to override individual variables for this call (and any
;; recursive calls). Returns the string result if :stream is nil or nil otherwise.
;;
;; The following keyword arguments can be passed with values:
;;   Keyword              Meaning                              Default value
;;   :stream              Writer for output or nil             *out*
;;   :base                Base to use for writing rationals    *print-base*
;;   :length              Maximum elements to show in sublists *print-length*
;;   :level               Maximum depth                        *print-level*
;;   :miser-width         Width to enter miser mode            *print-miser-width* ; #2
;;   :dispatch            The pretty print dispatch function   *print-pprint-dispatch*
;;   :pretty              If true, do pretty printing          *print-pretty*
;;   :radix               If true, prepend a radix specifier   *print-radix*
;;   :right-margin        The column for the right margin      *print-right-margin*
;;   :suppress-namespaces If true, no namespaces in symbols    *print-suppress-namespaces*