|
| 1 | +Changes to Clojure in Version 1.2 |
| 2 | + |
| 3 | += CONTENTS = |
| 4 | + |
| 5 | + 1 Deprecated and Removed Features |
| 6 | + 1.1 metadata reader macro is now ^ |
| 7 | + 2 New/Improved Features in clojure.core |
| 8 | + 2.1 Protocols, Records, and Types |
| 9 | + 2.2 Sequence Library |
| 10 | + 2.3 Destructuring |
| 11 | + 2.4 Case |
| 12 | + 2.5 Duplicate Key Prevention |
| 13 | + 2.6 Primitive Vectors |
| 14 | + 2.7 Agent Error Handling |
| 15 | + 2.8 Improved Ratio Support |
| 16 | + 2.9 Macro Implicit Args |
| 17 | + 2.10 Multimethod Enhancements |
| 18 | + 2.11 Function Metadata (Alpha) |
| 19 | + 2.12 Java Annotations |
| 20 | + 2.13 Namespace Collision Warnings |
| 21 | + 3 New Namespaces |
| 22 | + 3.1 clojure.java.io |
| 23 | + 3.1 clojure.java.javadoc |
| 24 | + 3.3 clojure.java.shell |
| 25 | + 3.4 clojure.pprint |
| 26 | + 3.5 clojure.repl |
| 27 | + 3.6 clojure.string |
| 28 | + 4 Functions with Improved Performance |
| 29 | + 5 Bug Fixes |
| 30 | + |
| 31 | += 1 Deprecated and Removed Features = |
| 32 | + |
| 33 | +== 1.1 metadata reader macro is now ^ == |
| 34 | + |
| 35 | +^ is the metadata reader macro. The former syntax #^ is deprecated and |
| 36 | +will be removed in a future version of Clojure. |
| 37 | + |
| 38 | + |
| 39 | += 2 New Features in clojure.core = |
| 40 | + |
| 41 | +== 2.1 Protocols, Records, Reify, and Types == |
| 42 | + |
| 43 | +defprotocol provides polymorphism without type intrusion. |
| 44 | + |
| 45 | +defrecord, reify, and deftype provide datatypes. They support, in a |
| 46 | +relatively clean manner, access to the highest-performance primitive |
| 47 | +representation and polymorphism mechanisms of the host. |
| 48 | + |
| 49 | +See http://clojure.org/protocols and http://clojure.org/datatypes for |
| 50 | +a more complete description. |
| 51 | + |
| 52 | + |
| 53 | +== 2.2 Sequence Library == |
| 54 | + |
| 55 | +The sequence library has several new functions in Clojure 1.2. The |
| 56 | +notes in parentheses indicate differences from the similarly-named |
| 57 | +functions in clojure-contrib. |
| 58 | + |
| 59 | + * flatten - New |
| 60 | + * frequencies - New |
| 61 | + * group-by - New (note: unsorted) |
| 62 | + * keep - New |
| 63 | + * keep-indexed - New (preferred over contrib's indexed for perf) |
| 64 | + * map-indexed - New (preferred over contrib's indexed for perf) |
| 65 | + * partition-all - New |
| 66 | + * partition-by - New |
| 67 | + * rand-nth - New (name indicates dependency on nth's perf) |
| 68 | + * range - Improved (added zero arity) |
| 69 | + * reductions - New |
| 70 | + * repeatedly - Improved! (added "do n times" semantics) |
| 71 | + * shuffle - New |
| 72 | + |
| 73 | + |
| 74 | +== 2.3 Destructuring Enhanced == |
| 75 | + |
| 76 | +If you associatively destructure a seq, it will be poured into a map first: |
| 77 | + |
| 78 | + (defn foo [& {:keys [a b c]}] |
| 79 | + [a b c]) |
| 80 | + |
| 81 | + (foo :c 3 :b 2) |
| 82 | + => [nil 2 3] |
| 83 | + |
| 84 | + |
| 85 | +== 2.4 Case == |
| 86 | + |
| 87 | +Case provides constant time dispatch on its clauses, which can be any |
| 88 | +compile-time literal |
| 89 | + |
| 90 | + (defn release-status |
| 91 | + [version] |
| 92 | + (case version |
| 93 | + (0.9 1.0 1.1) "History" |
| 94 | + 1.2 "Right now" |
| 95 | + :sentient "RSN")) |
| 96 | + |
| 97 | + |
| 98 | +== 2.5 Duplicate Key Prevention == |
| 99 | + |
| 100 | +Associative literals and their constructor functions hash-map and |
| 101 | +hash-set now prevent duplicate keys: |
| 102 | + |
| 103 | + #{1 1} |
| 104 | + => java.lang.IllegalArgumentException: Duplicate key: 1 |
| 105 | + |
| 106 | + |
| 107 | +== 2.6 Primitive Vectors == |
| 108 | + |
| 109 | +vector-of creates a vector of unboxed Java primitives, which follows |
| 110 | +the contract of Clojure vectors. |
| 111 | + |
| 112 | + |
| 113 | +== 2.7 Agent Error Handling == |
| 114 | + |
| 115 | +Agent error handling has been reworked in Clojure 1.2. |
| 116 | + |
| 117 | + * agent-error - New |
| 118 | + * restart-agent - New |
| 119 | + * set-error-handler - New |
| 120 | + * error-handler - New |
| 121 | + * set-error-mode! - New |
| 122 | + * error-mode - New |
| 123 | + * await - improved docstring, explains failed agent semantics |
| 124 | + * agent-errors - DEPRECATED |
| 125 | + * clear-agent-errors - DEPRECATED |
| 126 | + |
| 127 | + |
| 128 | +== 2.8 Improved Ratio Support == |
| 129 | + |
| 130 | + * numerator - New |
| 131 | + * denominator - New |
| 132 | + * bigint - Enhanced, now ratio aware |
| 133 | + |
| 134 | + |
| 135 | +== 2.9 Macro Implicit Args == |
| 136 | + |
| 137 | +Macros now have access to implicit arguments: |
| 138 | + |
| 139 | + * &form - the macro form |
| 140 | + * &env - the local bindings |
| 141 | + |
| 142 | + |
| 143 | +== 2.10 Multimethod Enhancements == |
| 144 | + |
| 145 | +Multimethods have been enhanced to improve interactive development: |
| 146 | + |
| 147 | + * remove-all-methods - New |
| 148 | + * defmulti - Enhanced to have defonce semantics |
| 149 | + |
| 150 | + |
| 151 | +== 2.11 Function Metadata == |
| 152 | + |
| 153 | +Clojure functions can now have metadata. Please treat this capability |
| 154 | +as alpha and subject to possible change or removal in a future version |
| 155 | +of Clojure. |
| 156 | + |
| 157 | + |
| 158 | +== 2.12 Java Annotations == |
| 159 | + |
| 160 | +Java Annotations can be added simply by making a Java annotation |
| 161 | +class a key in a Clojure metadata map: |
| 162 | + |
| 163 | + ;; Name is deprecated |
| 164 | + (defrecord ^{Deprecated true} Name [first last]) |
| 165 | + |
| 166 | +Please use Java annotations for interop purposes only. |
| 167 | + |
| 168 | +== 2.13 Namespace Collision Warnings == |
| 169 | + |
| 170 | +If a namespace defines a Var whose name collides with a name in the |
| 171 | +clojure.core namespace, you will see a warning but the definition will |
| 172 | +be allowed to proceed. This facilitates promoting useful functions |
| 173 | +into clojure.core without causing a breaking change. |
| 174 | + |
| 175 | +Please track down and fix these warnings, as matching names do not |
| 176 | +always imply matching semantics! |
| 177 | + |
| 178 | + |
| 179 | += 3 New Namespaces = |
| 180 | + |
| 181 | +Complete documentation for all namespaces is in the source and API |
| 182 | +docs: http://richhickey.github.com/clojure/ |
| 183 | + |
| 184 | + |
| 185 | +== 3.1 clojure.java.io == |
| 186 | + |
| 187 | +Java I/O libraries distilled from the duck-streams and io namespaces |
| 188 | +in clojure-contrib. |
| 189 | + |
| 190 | + |
| 191 | +== 3.2 clojure.java.javadoc == |
| 192 | + |
| 193 | +Launch a Javadoc browser from the REPL, promoted from the javadoc and |
| 194 | +repl-util namespace in clojure-contrib. |
| 195 | + |
| 196 | + |
| 197 | +== 3.3 clojure.java.shell == |
| 198 | + |
| 199 | +Utilities for launching a subprocess, promoted from shell-out |
| 200 | +namespace in clojure-contrib. |
| 201 | + |
| 202 | + |
| 203 | +== 3.4 clojure.pprint == |
| 204 | + |
| 205 | +Pretty-printer for Clojure, promoted from pprint in clojure-contrib. |
| 206 | + |
| 207 | + |
| 208 | +== 3.5 clojure.repl == |
| 209 | + |
| 210 | +Utilities for a more pleasant REPL experience, promoted from the |
| 211 | +repl-utils and ns-utils namespaces in clojure-contrib. |
| 212 | + |
| 213 | + |
| 214 | +== 3.6 clojure.string == |
| 215 | + |
| 216 | +String utilities promoted from the str-utils, str-utils2, str-utils3, |
| 217 | +and string namespaces in clojure-contrib. |
| 218 | + |
| 219 | + |
| 220 | += 4 Performance Enhancements = |
| 221 | + |
| 222 | +Many functions have improved performance in Clojure 1.2: |
| 223 | + |
| 224 | + aget |
| 225 | + array-map |
| 226 | + aset |
| 227 | + bit-shift-left |
| 228 | + bit-shift-right |
| 229 | + boolean |
| 230 | + byte |
| 231 | + count |
| 232 | + count |
| 233 | + double |
| 234 | + false? |
| 235 | + float |
| 236 | + future-call |
| 237 | + get |
| 238 | + get |
| 239 | + into |
| 240 | + keyword |
| 241 | + line-seq |
| 242 | + long |
| 243 | + nil? |
| 244 | + nth |
| 245 | + promise |
| 246 | + re-seq |
| 247 | + reduce |
| 248 | + resultset-seq |
| 249 | + set |
| 250 | + short |
| 251 | + true? |
| 252 | + vector |
| 253 | + |
| 254 | += 5 Bug Fixes = |
| 255 | + |
| 256 | +Please see the complete list at |
| 257 | +https://www.assembla.com/spaces/ticket_reports/show/13167?space_id=clojure. |
0 commit comments