|
181 | 181 | :jsdoc ["@type {*}"]}
|
182 | 182 | *loaded-libs* nil)
|
183 | 183 |
|
184 |
| -(defn- pr-opts [] |
185 |
| - {:flush-on-newline *flush-on-newline* |
186 |
| - :readably *print-readably* |
187 |
| - :meta *print-meta* |
188 |
| - :dup *print-dup* |
189 |
| - :print-length *print-length*}) |
190 |
| - |
191 | 184 | (declare into-array)
|
192 | 185 |
|
193 | 186 | (defn enable-console-print!
|
|
896 | 889 |
|
897 | 890 | ;; Printing support
|
898 | 891 |
|
| 892 | +(defn- pr-opts* |
| 893 | + [flush-on-newline readably meta dup print-length] |
| 894 | + (reify |
| 895 | + ILookup |
| 896 | + (-lookup [this k] |
| 897 | + (-lookup this k nil)) |
| 898 | + (-lookup [this k not-found] |
| 899 | + (case k |
| 900 | + :flush-on-newline flush-on-newline |
| 901 | + :readably readably |
| 902 | + :meta meta |
| 903 | + :dup dup |
| 904 | + :print-length print-length |
| 905 | + not-found)) |
| 906 | + IAssociative |
| 907 | + (-contains-key? [coll k] |
| 908 | + (case k |
| 909 | + :flush-on-newline true |
| 910 | + :readably true |
| 911 | + :meta true |
| 912 | + :dup true |
| 913 | + :print-length true |
| 914 | + false)) |
| 915 | + (-assoc [this k v] |
| 916 | + (case k |
| 917 | + :flush-on-newline (pr-opts* v readably meta dup print-length) |
| 918 | + :readably (pr-opts* flush-on-newline v meta dup print-length) |
| 919 | + :meta (pr-opts* flush-on-newline readably v dup print-length) |
| 920 | + :dup (pr-opts* flush-on-newline readably meta v print-length) |
| 921 | + :print-length (pr-opts* flush-on-newline readably meta dup v) |
| 922 | + this)))) |
| 923 | + |
| 924 | +(defn pr-opts [] |
| 925 | + (pr-opts* |
| 926 | + *flush-on-newline* |
| 927 | + *print-readably* |
| 928 | + *print-meta* |
| 929 | + *print-dup* |
| 930 | + *print-length*)) |
| 931 | + |
899 | 932 | (deftype StringBufferWriter [sb]
|
900 | 933 | IWriter
|
901 | 934 | (-write [_ s] (.append sb s))
|
@@ -10442,18 +10475,18 @@ reduces them without incurring seq initialization"
|
10442 | 10475 | (do
|
10443 | 10476 | (-write writer begin)
|
10444 | 10477 | (if (zero? (:print-length opts))
|
10445 |
| - (when (seq coll) |
| 10478 | + (when (-seq coll) |
10446 | 10479 | (-write writer (or (:more-marker opts) "...")))
|
10447 |
| - (do |
10448 |
| - (when (seq coll) |
10449 |
| - (print-one (first coll) writer opts)) |
10450 |
| - (loop [coll (next coll) n (dec (:print-length opts))] |
| 10480 | + (let [coll (-seq coll)] |
| 10481 | + (when coll |
| 10482 | + (print-one (-first coll) writer opts)) |
| 10483 | + (loop [coll (-next coll) n (dec (:print-length opts))] |
10451 | 10484 | (if (and coll (or (nil? n) (not (zero? n))))
|
10452 | 10485 | (do
|
10453 | 10486 | (-write writer sep)
|
10454 |
| - (print-one (first coll) writer opts) |
10455 |
| - (recur (next coll) (dec n))) |
10456 |
| - (when (and (seq coll) (zero? n)) |
| 10487 | + (print-one (-first coll) writer opts) |
| 10488 | + (recur (-next coll) (dec n))) |
| 10489 | + (when (and (-seq coll) (zero? n)) |
10457 | 10490 | (-write writer sep)
|
10458 | 10491 | (-write writer (or (:more-marker opts) "...")))))))
|
10459 | 10492 | (-write writer end)))))
|
@@ -11795,6 +11828,15 @@ reduces them without incurring seq initialization"
|
11795 | 11828 |
|
11796 | 11829 | (set! (.. ExceptionInfo -prototype -__proto__) js/Error.prototype)
|
11797 | 11830 |
|
| 11831 | +(extend-protocol ISeqable |
| 11832 | + nil |
| 11833 | + (-seq [this] nil) |
| 11834 | + |
| 11835 | + array |
| 11836 | + (-seq [this] |
| 11837 | + (when-not (zero? (alength this)) |
| 11838 | + (IndexedSeq. this 0 nil)))) |
| 11839 | + |
11798 | 11840 | (extend-type ExceptionInfo
|
11799 | 11841 | IPrintWithWriter
|
11800 | 11842 | (-pr-writer [obj writer opts]
|
|
0 commit comments