|
1 | 1 | <!-- -*- mode: markdown ; mode: visual-line ; coding: utf-8 -*- -->
|
2 | 2 |
|
| 3 | +# Changes to Clojure in Version 1.11.0 |
| 4 | + |
| 5 | +## 1 Compatibility |
| 6 | + |
| 7 | +### 1.1 Security |
| 8 | + |
| 9 | +Because XML external entity (XXE) attacks can be used to disclose local files using file schemes or relative paths in the system identifier, `clojure.xml/parse` now disables external entity processing by default. |
| 10 | + |
| 11 | +See: https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing |
| 12 | + |
| 13 | +This change disables the following SAX parser features: |
| 14 | + |
| 15 | +* `http://apache.org/xml/features/nonvalidating/load-external-dtd` |
| 16 | +* `http://xml.org/sax/features/external-general-entities` |
| 17 | +* `http://xml.org/sax/features/external-parameter-entities` |
| 18 | + |
| 19 | +If you rely on these features, modify your calls to `clojure.xml/parse` to explicitly |
| 20 | +supply `startparse-sax` function as the final argument: |
| 21 | +`(clojure.xml/parse the-string clojure.xml/startparse-sax)` |
| 22 | +This modification also works on prior Clojure versions. |
| 23 | + |
| 24 | +* [CLJ-2611](http://dev.clojure.org/jira/browse/CLJ-2611) clojure.xml now disables XXE processing by default |
| 25 | + |
| 26 | +### 1.2 Dependencies |
| 27 | + |
| 28 | +Updated dependencies: |
| 29 | + |
| 30 | +* spec.alpha dependency to 0.3.218 - [changes](https://github.com/clojure/spec.alpha/blob/master/CHANGES.md) |
| 31 | +* core.specs.alpha dependency to 0.2.62 - [changes](https://github.com/clojure/core.specs.alpha/blob/master/CHANGES.md) |
| 32 | + |
| 33 | +## 2 Features |
| 34 | + |
| 35 | +### 2.1 Keyword argument functions take a trailing map |
| 36 | + |
| 37 | +Keyword arguments are optional trailing variadic arguments of the form *akey aval bkey bval...*. |
| 38 | +In Clojure 1.11, functions taking keyword arguments can now be passed a map instead of or in addition |
| 39 | +to and following the key/value pairs. When a lone map is passed, it is used for destructuring, else |
| 40 | +a trailing map is added to the key/value pair map by `conj`. |
| 41 | + |
| 42 | +Also see: https://clojure.org/news/2021/03/18/apis-serving-people-and-programs |
| 43 | + |
| 44 | +* [CLJ-2603](https://clojure.atlassian.net/browse/CLJ-2603) Clojure keyword argument functions now also accept a map |
| 45 | + |
| 46 | +### 2.2 `:as-alias` in `require` |
| 47 | + |
| 48 | +Spec (and other libs) rely on qualified keywords as spec names. |
| 49 | +Namespace aliasing in `ns` makes long names shorter but required namespaces to be loadable. |
| 50 | +This change adds `:as-alias` to `require`, which is like `:as` but does not require the namespace to load. |
| 51 | + |
| 52 | +* [CLJ-2123](https://clojure.atlassian.net/browse/CLJ-2123) Add :as-alias option to require like :as but not load |
| 53 | +* [CLJ-2665](https://clojure.atlassian.net/browse/CLJ-2665) Fix require with :as and :as-alias to load |
| 54 | + |
| 55 | +## 3 New functions and namespaces |
| 56 | + |
| 57 | +### 3.1 clojure.math and numeric helper functions |
| 58 | + |
| 59 | +Added a new clojure.math namespace which provides wrappers for the functions available in java.lang.Math. |
| 60 | +These functions are narrowed to only `long` and `double` overloads and provide primitive support without reflection. |
| 61 | + |
| 62 | +In addition, the following functions were added to clojure.core: |
| 63 | + |
| 64 | +* `abs` - absolute value in optimized form for all Clojure numeric types (long, double, ratio, bigint, bigdecimal) |
| 65 | +* `NaN?` - predicate for doubles to check whether "not a number" |
| 66 | +* `infinite?` - predicate for doubles to check whether positive or negative infinity |
| 67 | + |
| 68 | +* [CLJ-2668](https://clojure.atlassian.net/browse/CLJ-2668) Add NaN? and infinite? predicates |
| 69 | +* [CLJ-2664](https://clojure.atlassian.net/browse/CLJ-2664) Add clojure.java.math namespace, wrappers for java.lang.Math |
| 70 | +* [CLJ-2673](https://clojure.atlassian.net/browse/CLJ-2673) Add `abs`, and update `min` and `max` to use Math impls when possible |
| 71 | +* [CLJ-2677](https://clojure.atlassian.net/browse/CLJ-2677) clojure.math - fix method reflection in bodies and inlines, fix docstrings, renamed |
| 72 | +* [CLJ-2689](https://clojure.atlassian.net/browse/CLJ-2689) Fix clojure.math tests to be more tolerant of floating point comparisons |
| 73 | + |
| 74 | +### 3.2 Parser functions |
| 75 | + |
| 76 | +Added the following parsing functions to clojure.core: |
| 77 | + |
| 78 | +* `parse-double` - parses floating point number, including scientific notation |
| 79 | +* `parse-long` - parses integer in long range |
| 80 | +* `parse-boolean` - parses `"true"` or `"false"` to the canonical boolean values |
| 81 | +* `parse-uuid` - parses a UUID string to java.util.UUID |
| 82 | + |
| 83 | +All of these functions expect a string argument and return either the parsed value or `nil` if the value |
| 84 | +is in invalid format. |
| 85 | + |
| 86 | +* [CLJ-2667](https://clojure.atlassian.net/browse/CLJ-2667) Add functions to parse a single long/double/uuid/boolean from a string |
| 87 | + |
| 88 | +### 3.2 `random-uuid` |
| 89 | + |
| 90 | +Added `random-uuid`, a function to construct a random java.util.UUID. |
| 91 | + |
| 92 | +* [CLJ-1925](https://clojure.atlassian.net/browse/CLJ-1925) Add random-uuid |
| 93 | + |
| 94 | +### 3.3 `update-keys` and `update-vals` |
| 95 | + |
| 96 | +Added: |
| 97 | + |
| 98 | +* `update-keys` - applies a function to every key in a map, `m f => {(f k) v ...}` |
| 99 | +* `update-vals` - applies a function to every value in a map, `m f => {k (f v) ...}` |
| 100 | + |
| 101 | +* [CLJ-1959](https://clojure.atlassian.net/browse/CLJ-1959) Add implementation of update-keys |
| 102 | +* [CLJ-2651](https://clojure.atlassian.net/browse/CLJ-2651) Add implementation of update-vals |
| 103 | + |
| 104 | +### 3.4 `iteration` |
| 105 | + |
| 106 | +Added `iteration`, to repeatedly apply a (possibly impure) step function with continuation state. |
| 107 | +This can be used e.g. to consume APIs that return paginated or batched data. |
| 108 | + |
| 109 | +* [CLJ-2555](https://clojure.atlassian.net/browse/CLJ-2555) Add `iteration` generator function |
| 110 | +* [CLJ-2690](https://clojure.atlassian.net/browse/CLJ-2690) Improve `iteration` docstring and arg names |
| 111 | +* [CLJ-2685](https://clojure.atlassian.net/browse/CLJ-2685) Fix `iteration` generative test failure |
| 112 | + |
| 113 | +## 4 Fixes |
| 114 | + |
| 115 | +### 4.1 Compiler |
| 116 | + |
| 117 | +* [CLJ-2680](https://clojure.atlassian.net/browse/CLJ-2680) Fix type hinting a primitive local with matching type hint to not error |
| 118 | +* [CLJ-1180](https://clojure.atlassian.net/browse/CLJ-1180) Fix resolution of class type hints in `defprotocol` |
| 119 | +* [CLJ-1973](https://clojure.atlassian.net/browse/CLJ-1973) Make order of emitted protocol methods in generated classes reproducible |
| 120 | + |
| 121 | +### 4.2 Core |
| 122 | + |
| 123 | +* [CLJ-1879](https://clojure.atlassian.net/browse/CLJ-1879) IKVReduce - make IPersistentMap case faster and extend to Object, detaching it from any fully enumerable set of types |
| 124 | +* [CLJ-2065](https://clojure.atlassian.net/browse/CLJ-2065) IKVReduce - add direct support for SubVector |
| 125 | +* [CLJ-2663](https://clojure.atlassian.net/browse/CLJ-2663) Fix vector `=` not terminating when called with infinite sequence |
| 126 | +* [CLJ-2679](https://clojure.atlassian.net/browse/CLJ-2679) Fix hash collisions in `case` expressions on symbols |
| 127 | +* [CLJ-2600](https://clojure.atlassian.net/browse/CLJ-2600) Don't block `realized?` of `delay` on pending result |
| 128 | +* [CLJ-2649](https://clojure.atlassian.net/browse/CLJ-2649) Fix order of checks in `some-fn` and `every-pred` for 3 predicate case to match other unrollings |
| 129 | +* [CLJ-2234](https://clojure.atlassian.net/browse/CLJ-2234) Fix multimethod preferences to correctly use local hierarchy when it exists |
| 130 | +* [CLJ-2556](https://clojure.atlassian.net/browse/CLJ-2556) Fix `into` completion so `halt-when` works |
| 131 | + |
| 132 | +### 4.3 Performance |
| 133 | + |
| 134 | +* [CLJ-1808](https://clojure.atlassian.net/browse/CLJ-1808) `map-invert` should use `reduce-kv` and transient |
| 135 | +* [CLJ-2621](https://clojure.atlassian.net/browse/CLJ-2621) Fix unnecessary boxing of unused return in statement context for instance method expr |
| 136 | +* [CLJ-2670](https://clojure.atlassian.net/browse/CLJ-2670) Use Math.exact... methods for checked long math ops for performance |
| 137 | +* [CLJ-2636](https://clojure.atlassian.net/browse/CLJ-2636) Get rid of reflection on java.util.Properties when defining `*clojure-version*` |
| 138 | +* [CLJ-1509](https://clojure.atlassian.net/browse/CLJ-1509) AOT compile clojure.instant, clojure.uuid, clojure.core.reducers in build |
| 139 | + |
| 140 | +### 4.4 Error messages |
| 141 | + |
| 142 | +* [CLJ-2529](https://clojure.atlassian.net/browse/CLJ-2529) Fix incorrect reporting of runtime errors as compiler errors in calls through `Compiler.load()` |
| 143 | +* [CLJ-2350](https://clojure.atlassian.net/browse/CLJ-2350) Improve keyword arity exception message |
| 144 | + |
| 145 | +### 4.5 Docstrings |
| 146 | + |
| 147 | +* [CLJ-2249](https://clojure.atlassian.net/browse/CLJ-2249) Clarify `get` docstring regarding sets, strings, arrays, ILookup |
| 148 | +* [CLJ-2488](https://clojure.atlassian.net/browse/CLJ-2488) Add definition to `reify` docstring |
| 149 | +* [CLJ-1360](https://clojure.atlassian.net/browse/CLJ-1360) Update `clojure.string/split` docstring regarding trailing empty parts |
| 150 | +* [CLJ-2444](https://clojure.atlassian.net/browse/CLJ-2444) Fix typo in `test-vars` docstring |
| 151 | +* [CLJ-2666](https://clojure.atlassian.net/browse/CLJ-2666) Make Clojure Java API javadoc text match the example |
| 152 | + |
| 153 | +### 4.6 Other enhancements |
| 154 | + |
| 155 | +* [CLJ-2493](https://clojure.atlassian.net/browse/CLJ-2493) clojure.java.browse - Fix `browse-url` hanging on call to xdg-open |
| 156 | +* [CLJ-1908](https://clojure.atlassian.net/browse/CLJ-1908) clojure.test - Add `run-test` and `run-test-var` to run single test with fixtures and report |
| 157 | +* [CLJ-1379](https://clojure.atlassian.net/browse/CLJ-1379) clojure.test - Fix quoting of `:actual` form in `:pass` maps |
| 158 | +* [CLJ-2620](https://clojure.atlassian.net/browse/CLJ-2620) clojure.server - Fix asymmetric handling of `:exception` `:val`s in `prepl` |
| 159 | +* [CLJ-2387](https://clojure.atlassian.net/browse/CLJ-2387) clojure.server - Fix off-by-one in socket server port validation |
| 160 | + |
| 161 | + |
3 | 162 | # Changes to Clojure in Version 1.10.3
|
4 | 163 |
|
5 | 164 | ## 1 Changes reverted
|
|
0 commit comments