aboutsummaryrefslogtreecommitdiff
path: root/src/clojure/contrib/pprint
diff options
context:
space:
mode:
authorTom Faulhaber <git_net@infolace.com>2009-06-13 06:07:09 +0000
committerTom Faulhaber <git_net@infolace.com>2009-06-13 06:07:09 +0000
commitd5fc2809405d09e46e6b92933c28747b3e579860 (patch)
tree2e940db25195fbacda80a025d1120131d1c7370b /src/clojure/contrib/pprint
parent356604ca0ec38bf3fbe5a15de715e30142cc3937 (diff)
pprint: directly call some dispatch functions that we use often to be
easier on the stack
Diffstat (limited to 'src/clojure/contrib/pprint')
-rw-r--r--src/clojure/contrib/pprint/dispatch.clj42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/clojure/contrib/pprint/dispatch.clj b/src/clojure/contrib/pprint/dispatch.clj
index c27db51d..89ea6b5c 100644
--- a/src/clojure/contrib/pprint/dispatch.clj
+++ b/src/clojure/contrib/pprint/dispatch.clj
@@ -60,13 +60,49 @@
;;; are a little easier on the stack. (Or, do "real" compilation, a
;;; la Common Lisp)
-(def pprint-simple-list (formatter-out "~:<~@{~w~^ ~_~}~:>"))
+;;; (def pprint-simple-list (formatter-out "~:<~@{~w~^ ~_~}~:>"))
+(defn pprint-simple-list [alis]
+ (pprint-logical-block :prefix "(" :suffix ")"
+ (loop [alis (seq alis)]
+ (when alis
+ (write-out (first alis))
+ (when (next alis)
+ (.write #^java.io.Writer *out* " ")
+ (pprint-newline :linear)
+ (recur (next alis)))))))
+
(defn pprint-list [alis]
(if-not (pprint-reader-macro alis)
(pprint-simple-list alis)))
-(def pprint-vector (formatter-out "~<[~;~@{~w~^ ~_~}~;]~:>"))
+
+;;; (def pprint-vector (formatter-out "~<[~;~@{~w~^ ~_~}~;]~:>"))
+(defn pprint-vector [avec]
+ (pprint-logical-block :prefix "[" :suffix "]"
+ (loop [aseq (seq avec)]
+ (when aseq
+ (write-out (first aseq))
+ (when (next aseq)
+ (.write #^java.io.Writer *out* " ")
+ (pprint-newline :linear)
+ (recur (next aseq)))))))
+
(def pprint-array (formatter-out "~<[~;~@{~w~^, ~:_~}~;]~:>"))
-(def pprint-map (formatter-out "~<{~;~@{~<~w~^ ~_~w~:>~^, ~_~}~;}~:>"))
+
+;;; (def pprint-map (formatter-out "~<{~;~@{~<~w~^ ~_~w~:>~^, ~_~}~;}~:>"))
+(defn pprint-map [amap]
+ (pprint-logical-block :prefix "{" :suffix "}"
+ (loop [aseq (seq amap)]
+ (when aseq
+ (pprint-logical-block
+ (write-out (ffirst aseq))
+ (.write #^java.io.Writer *out* " ")
+ (pprint-newline :linear)
+ (write-out (fnext (first aseq))))
+ (when (next aseq)
+ (.write #^java.io.Writer *out* ", ")
+ (pprint-newline :linear)
+ (recur (next aseq)))))))
+
(def pprint-set (formatter-out "~<#{~;~@{~w~^ ~:_~}~;}~:>"))
(defn pprint-ref [ref]
(pprint-logical-block :prefix "#<Ref " :suffix ">"