2
2
3
3
# Changes to Clojure in Version 1.7
4
4
5
- ## 1 New and Improved Features
5
+ ## 1 Compatibility Notes
6
6
7
- ### 1.1 Transducers
7
+ Please be aware of the following issues when upgrading to Clojure 1.7.
8
+
9
+ ### Seqs on Java iterators that return the same mutating object
10
+
11
+ Seqs are fundamentally incompatible with Java iterators that return
12
+ the same mutating object on every call to next(). Some Clojure
13
+ libraries incorrectly rely on calling seq on such iterators.
14
+
15
+ In 1.7, iterator-seqs are chunked, which will cause many of these
16
+ incorrect usages to return incorrect results immediately.
17
+
18
+ The ` seq ` and ` iterator-seq ` docstrings have been updated to include
19
+ an explicit warning. Libraries that incorrectly use ` seq ` and
20
+ ` iterator-seq ` will need to be fixed before running against 1.7.
21
+
22
+ * [ CLJ-1669] ( http://dev.clojure.org/jira/browse/CLJ-1669 )
23
+ * [ CLJ-1738] ( http://dev.clojure.org/jira/browse/CLJ-1738 )
24
+
25
+ ### Thread owner check removed on transients
26
+
27
+ Prior to Clojure 1.7, transients would allow modification only from the
28
+ thread that created the transient. This check has been removed. It is
29
+ still a requirement that transients should be updated by only a single
30
+ thread at a time.
31
+
32
+ This constraint was relaxed to allow transients to be used in cases where
33
+ code is multiplexed across multiple threads in a pool (such as go blocks
34
+ in core.async).
35
+
36
+ ### keys/vals require custom map type to implement Iterable
37
+
38
+ Invoking ` keys ` or ` vals ` on a custom map type that implements IPersistentMap
39
+ will now use the Iterable iterator() method instead of accessing entries
40
+ via the seq of the map. There have been no changes in the type hierarchy
41
+ (IPersistentMap has always extended Iterable) but former map-like instances
42
+ may have skipped implementing this method in the past.
43
+
44
+ * [ CLJ-1602] ( http://dev.clojure.org/jira/browse/CLJ-1602 )
45
+
46
+ ## 2 New and Improved Features
47
+
48
+ ### 2.1 Transducers
8
49
9
50
Transducers is a new way to decouple algorithmic transformations from their
10
51
application in different contexts. Transducers are functions that transform
@@ -16,7 +57,6 @@ Many existing sequence functions now have a new arity (one fewer argument
16
57
than before). This arity will return a transducer that represents the same
17
58
logic but is independent of lazy sequence processing. Functions included are:
18
59
19
- * conj (conjs to [ ] )
20
60
* map
21
61
* mapcat
22
62
* filter
@@ -38,7 +78,7 @@ logic but is independent of lazy sequence processing. Functions included are:
38
78
Additionally some new transducer functions have been added:
39
79
40
80
* cat - concatenates the contents of each input
41
- * de-dupe - removes consecutive duplicated values
81
+ * dedupe - removes consecutive duplicated values
42
82
* random-sample - returns items from coll with random probability
43
83
44
84
And this function can be used to make completing transforms:
@@ -51,12 +91,12 @@ transducers in different ways:
51
91
* sequence - takes a transformation and a coll and produces a lazy seq
52
92
* transduce - reduce with a transformation (eager)
53
93
* eduction - returns a reducible/iterable of applications of the transducer to items in coll. Applications are re-performed with every reduce/iterator.
54
- * run! - run the transformation for side effects on the collection
55
94
56
95
There have been a number of internal changes to support transducers:
57
96
58
97
* volatiles - there are a new set of functions (volatile!, vswap!, vreset!, volatile?) to create and use volatile "boxes" to hold state in stateful transducers. Volatiles are faster than atoms but give up atomicity guarantees so should only be used with thread isolation.
59
98
* array iterators - added support for iterators over arrays
99
+ * conj can be used as a reducing function and will conj to [ ]
60
100
61
101
Some related issues addressed during development:
62
102
* [ CLJ-1511] ( http://dev.clojure.org/jira/browse/CLJ-1511 )
@@ -73,7 +113,7 @@ Some related issues addressed during development:
73
113
* [ CLJ-1669] ( http://dev.clojure.org/jira/browse/CLJ-1669 )
74
114
* [ CLJ-1723] ( http://dev.clojure.org/jira/browse/CLJ-1723 )
75
115
76
- ### 1 .2 Reader Conditionals
116
+ ### 2 .2 Reader Conditionals
77
117
78
118
Reader Conditionals are a new capability to support portable code that
79
119
can run on multiple Clojure platforms with only small changes. In
@@ -88,13 +128,14 @@ prior to .cljc.
88
128
A new reader form can be used to specify "reader conditional" code in
89
129
cljc files (and * only* cljc files). Each platform defines a feature
90
130
identifying the platform (: clj , : cljs , : cljr ). The reader conditional
91
- specifies code that is read conditionally based on the feature/
131
+ specifies code that is read conditionally based on the feature. The
132
+ REPL also allows reader conditionals.
92
133
93
134
Form #? takes a list of alternating feature and expression. These are
94
135
checked like cond and the selected expression is read and returned. Other
95
- branches are unread . If no branch is selected, the reader reads nothing
96
- (not nil, but literally as if reading "" ). An optional " : default " branch
97
- can be used as a fallthrough.
136
+ branches are read but skipped . If no branch is selected, the reader reads
137
+ nothing (not nil, but literally as if reading no form ). An optional
138
+ ` :default ` branch can be used as a fallthrough.
98
139
99
140
Reader conditional with 2 features and a default:
100
141
@@ -104,14 +145,14 @@ Reader conditional with 2 features and a default:
104
145
105
146
There is also a reader conditional splicing form. The evaluated expression
106
147
should be sequential and will be spliced into the surrounded code, similar
107
- to unqoute -splicing.
148
+ to unquote -splicing.
108
149
109
150
For example:
110
151
111
152
[ 1 2 #?@(: clj [ 3 4] : cljs [ 5 6] )]
112
153
113
154
This form would read as [ 1 2 3 4] on Clojure, [ 1 2 5 6] on ClojureScript,
114
- and [ 1 2] on any other platform.
155
+ and [ 1 2] on any other platform. Splicing is not allowed at the top level.
115
156
116
157
Additionally, the reader can now be invoked with options for the features
117
158
to use and how to interpret reader conditionals. By default, reader conditionals
@@ -130,8 +171,9 @@ http://dev.clojure.org/display/design/Reader+Conditionals
130
171
* [ CLJ-1699] ( http://dev.clojure.org/jira/browse/CLJ-1699 )
131
172
* [ CLJ-1700] ( http://dev.clojure.org/jira/browse/CLJ-1700 )
132
173
* [ CLJ-1728] ( http://dev.clojure.org/jira/browse/CLJ-1728 )
174
+ * [ CLJ-1706] ( http://dev.clojure.org/jira/browse/CLJ-1706 )
133
175
134
- ### 1 .3 Keyword and Symbol Construction
176
+ ### 2 .3 Keyword and Symbol Construction
135
177
136
178
In response to issues raised in [ CLJ-1439] ( http://dev.clojure.org/jira/browse/CLJ-1439 ) ,
137
179
several changes have been made in symbol and keyword construction:
@@ -143,7 +185,7 @@ in a performance increase.
143
185
2 ) Keywords are cached and keyword construction includes a cache check. A change was made
144
186
to only clear the cache reference queue when there is a cache miss.
145
187
146
- ### 1 .4 Warn on Boxed Math
188
+ ### 2 .4 Warn on Boxed Math
147
189
148
190
One source of performance issues is the (unintended) use of arithmetic operations on
149
191
boxed numbers. To make detecting the presence of boxed math easier, a warning will now
@@ -167,7 +209,7 @@ Example use:
167
209
* [ CLJ-1535] ( http://dev.clojure.org/jira/browse/CLJ-1535 )
168
210
* [ CLJ-1642] ( http://dev.clojure.org/jira/browse/CLJ-1642 )
169
211
170
- ### 1 .5 update - like update-in for first level
212
+ ### 2 .5 update - like update-in for first level
171
213
172
214
` update ` is a new function that is like update-in specifically for first-level keys:
173
215
@@ -184,7 +226,7 @@ Example use:
184
226
185
227
* [ CLJ-1251] ( http://dev.clojure.org/jira/browse/CLJ-1251 )
186
228
187
- ### 1 .6 Faster reduce and iterator paths
229
+ ### 2 .6 Faster reduce and iterator paths
188
230
189
231
Several important Clojure functions now return sequences that also
190
232
contain fast reduce() (or in some cases iterator()) paths. In many
@@ -221,7 +263,7 @@ eduction.
221
263
* [ CLJ-1726] ( http://dev.clojure.org/jira/browse/CLJ-1726 )
222
264
* [ CLJ-1727] ( http://dev.clojure.org/jira/browse/CLJ-1727 )
223
265
224
- ### 1 .7 Printing as data
266
+ ### 2 .7 Printing as data
225
267
226
268
There have been enhancements in how the REPL prints values without a
227
269
print-method, specifically Throwable and the fallthrough Object case.
@@ -256,19 +298,26 @@ map data: `Throwable->map`.
256
298
257
299
* [ CLJ-1703] ( http://dev.clojure.org/jira/browse/CLJ-1703 )
258
300
* [ CLJ-1716] ( http://dev.clojure.org/jira/browse/CLJ-1716 )
301
+ * [ CLJ-1735] ( http://dev.clojure.org/jira/browse/CLJ-1735 )
259
302
260
- ## 2 Enhancements
303
+ ### 2.8 run!
261
304
262
- ### 2.1 Error messages
305
+ run! is a new function that takes a side effect reducing function and runs
306
+ it for all items in a collection via reduce. The accumulator is ignored and
307
+ nil is returned.
308
+
309
+ (run! println (range 10))
310
+
311
+ ## 3 Enhancements
312
+
313
+ ### 3.1 Error messages
263
314
264
315
* [ CLJ-1261] ( http://dev.clojure.org/jira/browse/CLJ-1261 )
265
316
Invalid defrecord results in exception attributed to consuming ns instead of defrecord ns
266
- * [ CLJ-1169] ( http://dev.clojure.org/jira/browse/CLJ-1169 )
267
- Report line,column, and source in defmacro errors
268
317
* [ CLJ-1297] ( http://dev.clojure.org/jira/browse/CLJ-1297 )
269
318
Give more specific hint if namespace with "-" not found to check file uses "_ "
270
319
271
- ### 2 .2 Documentation strings
320
+ ### 3 .2 Documentation strings
272
321
273
322
* [ CLJ-1417] ( http://dev.clojure.org/jira/browse/CLJ-1417 )
274
323
clojure.java.io/input-stream has incorrect docstring
@@ -282,8 +331,10 @@ map data: `Throwable->map`.
282
331
Fix typo in deftype docstring
283
332
* [ CLJ-1478] ( http://dev.clojure.org/jira/browse/CLJ-1378 )
284
333
Fix typo in clojure.main usage
334
+ * [ CLJ-1738] ( http://dev.clojure.org/jira/browse/CLJ-1738 )
335
+ Clarify usage on Java iterators in seq and iterator-seq
285
336
286
- ### 2 .3 Performance
337
+ ### 3 .3 Performance
287
338
288
339
* [ CLJ-1430] ( http://dev.clojure.org/jira/browse/CLJ-1430 )
289
340
Improve performance of partial with more unrolling
@@ -300,7 +351,7 @@ map data: `Throwable->map`.
300
351
* [ CLJ-1695] ( http://dev.clojure.org/jira/browse/CLJ-1695 )
301
352
Fixed reflection call in variadic vector-of constructor
302
353
303
- ### 2 .4 Other enhancements
354
+ ### 3 .4 Other enhancements
304
355
305
356
* [ CLJ-1191] ( http://dev.clojure.org/jira/browse/CLJ-1191 )
306
357
Improve apropos to show some indication of namespace of symbols found
@@ -331,7 +382,7 @@ map data: `Throwable->map`.
331
382
* [ CLJ-1683] ( http://dev.clojure.org/jira/browse/CLJ-1683 )
332
383
Change reduce tests to better catch reduce without init bugs
333
384
334
- ## 3 Bug Fixes
385
+ ## 4 Bug Fixes
335
386
336
387
* [ CLJ-1362] ( http://dev.clojure.org/jira/browse/CLJ-1362 )
337
388
Reduce broken on some primitive vectors
@@ -389,6 +440,8 @@ map data: `Throwable->map`.
389
440
Use equals() instead of == when resolving Symbol
390
441
* [ CLJ-1195] ( http://dev.clojure.org/jira/browse/CLJ-1195 )
391
442
emit-hinted-impl expands to ns-qualified invocation of fn
443
+ * [ CLJ-1237] ( http://dev.clojure.org/jira/browse/CLJ-1237 )
444
+ reduce of sequence that switches between chunked and unchunked many times throws StackOverflow
392
445
393
446
# Changes to Clojure in Version 1.6
394
447
0 commit comments