|
| 1 | +Julia v1.5 Release Notes |
| 2 | +======================== |
| 3 | + |
| 4 | +New language features |
| 5 | +--------------------- |
| 6 | + |
| 7 | +* Macro calls `@foo {...}` can now also be written `@foo{...}` (without the space) ([#34498]). |
| 8 | +* `⨟` is now parsed as a binary operator with times precedence. It can be entered in the REPL |
| 9 | + with `\bbsemi` followed by <kbd>TAB</kbd> ([#34722]). |
| 10 | +* `±` and `∓` are now unary operators as well, like `+` or `-`. Attention has to be paid in |
| 11 | + macros and matrix constructors, which are whitespace sensitive, because expressions like |
| 12 | + `[a ±b]` now get parsed as `[a ±(b)]` instead of `[±(a, b)]` ([#34200]). |
| 13 | +* Passing an identifier `x` by itself as a keyword argument or named tuple element |
| 14 | + is equivalent to `x=x`, implicitly using the name of the variable as the keyword |
| 15 | + or named tuple field name. |
| 16 | + Similarly, passing an `a.b` expression uses `b` as the keyword or field name ([#29333]). |
| 17 | +* Support for Unicode 13.0.0 (via utf8proc 2.5) ([#35282]). |
| 18 | +* The compiler optimization level can now be set per-module using the experimental macro |
| 19 | + `Base.Experimental.@optlevel n`. For code that is not performance-critical, setting |
| 20 | + this to 0 or 1 can provide significant latency improvements ([#34896]). |
| 21 | + |
| 22 | +Language changes |
| 23 | +---------------- |
| 24 | + |
| 25 | +* The interactive REPL now uses "soft scope" for top-level expressions: an assignment inside a |
| 26 | + scope block such as a `for` loop automatically assigns to a global variable if one has been |
| 27 | + defined already. This matches the behavior of Julia versions 0.6 and prior, as well as |
| 28 | + [IJulia](https://github.com/JuliaLang/IJulia.jl). |
| 29 | + Note that this only affects expressions interactively typed or pasted directly into the |
| 30 | + default REPL ([#28789], [#33864]). |
| 31 | +* Outside of the REPL (e.g. in a file), assigning to a variable within a top-level scope |
| 32 | + block is considered ambiguous if a global variable with the same name exists. |
| 33 | + A warning is given if that happens, to alert you that the code will work differently |
| 34 | + than in the REPL. |
| 35 | + A new command line option `--warn-scope` controls this warning ([#33864]). |
| 36 | +* Converting arbitrary tuples to `NTuple`, e.g. `convert(NTuple, (1, ""))` now gives an error, |
| 37 | + where it used to be incorrectly allowed. This is because `NTuple` refers only to homogeneous |
| 38 | + tuples (this meaning has not changed) ([#34272]). |
| 39 | +* The syntax `(;)` (which was deprecated in v1.4) now creates an empty named tuple ([#30115]). |
| 40 | +* `@inline` macro can now be applied to short-form anonymous functions ([#34953]). |
| 41 | +* In triple-quoted string literals, whitespace stripping is now done before processing |
| 42 | + escape sequences instead of after. For example, the syntax |
| 43 | + ``` |
| 44 | + """ |
| 45 | + a\n b""" |
| 46 | + ``` |
| 47 | + used to yield the string " a\nb", since the single space before `b` set the indent level. |
| 48 | + Now the result is "a\n b", since the space before `b` is no longer considered to occur |
| 49 | + at the start of a line. The old behavior is considered a bug ([#35001]). |
| 50 | +* `<:` and `>:` can now be broadcasted over arrays with `.<:` and `.>:` ([#35085]) |
| 51 | +* The line number of function definitions is now added by the parser as an |
| 52 | + additional `LineNumberNode` at the start of each function body ([#35138]). |
| 53 | +* Statements of the form `a'` now get lowered to `var"'"(a)` instead of `Base.adjoint(a)`. This |
| 54 | + allows for shadowing this function in local scopes, although this is generally discouraged. |
| 55 | + By default, Base exports `var"'"` as an alias of `Base.adjoint`, so custom types should still |
| 56 | + extend `Base.adjoint` ([#34634]). |
| 57 | + |
| 58 | +Compiler/Runtime improvements |
| 59 | +----------------------------- |
| 60 | + |
| 61 | +* Immutable structs (including tuples) that contain references can now be allocated |
| 62 | + on the stack, and allocated inline within arrays and other structs ([#33886]). |
| 63 | + This significantly reduces the number of heap allocations in some workloads. |
| 64 | + Code that requires assumptions about object layout and addresses (usually for |
| 65 | + interoperability with C or other languages) might need to be updated; for |
| 66 | + example any object that needs a stable address should be a `mutable struct`. |
| 67 | + |
| 68 | +Command-line option changes |
| 69 | +--------------------------- |
| 70 | + |
| 71 | +* Deprecation warnings are no longer shown by default. i.e. if the `--depwarn=...` flag is |
| 72 | + not passed it defaults to `--depwarn=no`. The warnings are printed from tests run by |
| 73 | + `Pkg.test()` ([#35362]). |
| 74 | +* Color now defaults to on when stdout and stderr are TTYs ([#34347]). |
| 75 | +* `-t N`, `--threads N` starts Julia with `N` threads. This option takes precedence over |
| 76 | + `JULIA_NUM_THREADS`. The specified number of threads also propagates to worker |
| 77 | + processes spawned using the `-p`/`--procs` or `--machine-file` command line arguments. |
| 78 | + In order to set number of threads for worker processes spawned with `addprocs` use the |
| 79 | + `exeflags` keyword argument, e.g. ```addprocs(...; exeflags=`--threads 4`)``` ([#35108]). |
| 80 | + |
| 81 | +Multi-threading changes |
| 82 | +----------------------- |
| 83 | + |
| 84 | +* Parts of the multi-threading API are now considered stable, with caveats. |
| 85 | + This includes all documented identifiers from `Base.Threads` except the |
| 86 | + `atomic_` operations. |
| 87 | +* `@threads` now allows an optional schedule argument. Use `@threads :static ...` to |
| 88 | + ensure that the same schedule will be used as in past versions; the default schedule |
| 89 | + is likely to change in the future. |
| 90 | + |
| 91 | +Build system changes |
| 92 | +-------------------- |
| 93 | + |
| 94 | +* The build system now contains a pure-make caching system for expanding expensive operations at the latest |
| 95 | + possible moment, while still expanding it only once ([#35626]). |
| 96 | + |
| 97 | +New library functions |
| 98 | +--------------------- |
| 99 | + |
| 100 | +* Packages can now provide custom hints to help users resolve errors by using the |
| 101 | + experimental `Base.Experimental.register_error_hint` function. |
| 102 | + Packages that define custom exception types can support hints by calling the |
| 103 | + `Base.Experimental.show_error_hints` from their `showerror` method ([#35094]). |
| 104 | +* The `@ccall` macro has been added to Base. It is a near drop-in replacement for `ccall` with more Julia-like syntax. It also wraps the new `foreigncall` API for varargs of different types, though it lacks the capability to specify an LLVM calling convention ([#32748]). |
| 105 | +* New functions `mergewith` and `mergewith!` supersede `merge` and `merge!` with `combine` |
| 106 | + argument. They don't have the restriction for `combine` to be a `Function` and also |
| 107 | + provide one-argument method that returns a closure. The old methods of `merge` and |
| 108 | + `merge!` are still available for backward compatibility ([#34296]). |
| 109 | +* The new `isdisjoint` function indicates whether two collections are disjoint ([#34427]). |
| 110 | +* Add function `ismutable` and deprecate `isimmutable` to check whether something is mutable ([#34652]). |
| 111 | +* `include` now accepts an optional `mapexpr` first argument to transform the parsed |
| 112 | + expressions before they are evaluated ([#34595]). |
| 113 | +* New function `bitreverse` for reversing the order of bits in a fixed-width integer ([#34791]). |
| 114 | +* New function `bitrotate(x, k)` for rotating the bits in a fixed-width integer ([#33937]). |
| 115 | +* New function `contains(haystack, needle)` and its one argument partially applied form have been added, it acts like `occursin(needle, haystack)` ([#35132]). |
| 116 | +* New function `Base.exit_on_sigint` is added to control if `InterruptException` is |
| 117 | + thrown by Ctrl-C ([#29411]). |
| 118 | + |
| 119 | +New library features |
| 120 | +-------------------- |
| 121 | + |
| 122 | +* Function composition now works also on one argument `∘(f) = f` (#34251). |
| 123 | +* One argument methods `startswith(x)` and `endswith(x)` have been added, returning partially-applied versions of the functions, similar to existing methods like `isequal(x)` ([#33193]). |
| 124 | +* `isapprox` (or `≈`) now has a one-argument "curried" method `isapprox(x)` which returns a function, like `isequal` (or `==`) ([#32305]). |
| 125 | +* `@NamedTuple{key1::Type1, ...}` macro for convenient `NamedTuple` declarations ([#34548]). |
| 126 | +* `Ref{NTuple{N,T}}` can be passed to `Ptr{T}`/`Ref{T}` `ccall` signatures ([#34199]). |
| 127 | +* `x::Signed % Unsigned` and `x::Unsigned % Signed` are supported for integer bitstypes. |
| 128 | +* `signed(unsigned_type)` is supported for integer bitstypes, `unsigned(signed_type)` has been supported. |
| 129 | +* `accumulate`, `cumsum`, and `cumprod` now support `Tuple` ([#34654]) and arbitrary iterators ([#34656]). |
| 130 | +* `pop!(collection, key, [default])` now has a method for `Vector` to remove an element at an arbitrary index ([#35513]). |
| 131 | +* In `splice!` with no replacement, values to be removed can now be specified with an |
| 132 | + arbitrary iterable (instead of a `UnitRange`) ([#34524]). |
| 133 | +* The `@view` and `@views` macros now support the `a[begin]` syntax that was introduced in Julia 1.4 ([#35289]). |
| 134 | +* `open` for files now accepts a keyword argument `lock` controlling whether file operations |
| 135 | + will acquire locks for safe multi-threaded access. Setting it to `false` provides better |
| 136 | + performance when only one thread will access the file ([#35426]). |
| 137 | +* The introspection macros (`@which`, `@code_typed`, etc.) now work with `do`-block syntax ([#35283]) and with dot syntax ([#35522]). |
| 138 | +* `count` now accepts the `dims` keyword. |
| 139 | +* new in-place `count!` function similar to `sum!`. |
| 140 | +* `peek` is now exported and accepts a type to peek from a stream ([#28811]). |
| 141 | + |
| 142 | +Standard library changes |
| 143 | +------------------------ |
| 144 | + |
| 145 | +* Empty ranges now compare equal, regardless of their startpoint and step ([#32348]). |
| 146 | +* A 1-d `Zip` iterator (where `Base.IteratorSize` is `Base.HasShape{1}()`) with defined length of `n` has now also size of `(n,)` (instead of throwing an error with truncated iterators) ([#29927]). |
| 147 | +* The `@timed` macro now returns a `NamedTuple` ([#34149]). |
| 148 | +* New `supertypes(T)` function returns a tuple of all supertypes of `T` ([#34419]). |
| 149 | +* Views of builtin ranges are now recomputed ranges (like indexing returns) instead of |
| 150 | + `SubArray`s ([#26872]). |
| 151 | +* Sorting-related functions such as `sort` that take the keyword arguments `lt`, `rev`, `order` |
| 152 | + and `by` now do not discard `order` if `by` or `lt` are passed. In the former case, the |
| 153 | + order from `order` is used to compare the values of `by(element)`. In the latter case, |
| 154 | + any order different from `Forward` or `Reverse` will raise an error about the |
| 155 | + ambiguity. |
| 156 | +* `close` on a file (`IOStream`) can now throw an exception if an error occurs when trying |
| 157 | + to flush buffered data to disk ([#35303]). |
| 158 | +* The large `StridedArray` `Union` now has special printing to avoid printing out its entire |
| 159 | + contents ([#31149]). |
| 160 | + |
| 161 | +#### LinearAlgebra |
| 162 | + |
| 163 | +* The BLAS submodule now supports the level-2 BLAS subroutine `hpmv!` ([#34211]). |
| 164 | +* `normalize` now supports multidimensional arrays ([#34239]). |
| 165 | +* `lq` factorizations can now be used to compute the minimum-norm solution to under-determined systems ([#34350]). |
| 166 | +* `sqrt(::Hermitian)` now treats slightly negative eigenvalues as zero for nearly semidefinite matrices, and accepts a new `rtol` keyword argument for this tolerance ([#35057]). |
| 167 | +* The BLAS submodule now supports the level-2 BLAS subroutine `spmv!` ([#34320]). |
| 168 | +* The BLAS submodule now supports the level-1 BLAS subroutine `rot!` ([#35124]). |
| 169 | +* New generic `rotate!(x, y, c, s)` and `reflect!(x, y, c, s)` functions ([#35124]). |
| 170 | + |
| 171 | +#### Markdown |
| 172 | + |
| 173 | +* In docstrings, a level-1 markdown header "Extended help" is now interpreted as a marker |
| 174 | + dividing "brief help" from "extended help". The REPL help mode only shows the brief help |
| 175 | + (the content before the "Extended help" header) by default; prepend the expression with '?' |
| 176 | + (in addition to the one that enters the help mode) to see the full docstring ([#25930]). |
| 177 | + |
| 178 | +#### Random |
| 179 | + |
| 180 | +* `randn!(::MersenneTwister, ::Array{Float64})` is faster, and as a result, for a given state of the RNG, |
| 181 | + the corresponding generated numbers have changed ([#35078]). |
| 182 | +* `rand!(::MersenneTwister, ::Array{Bool})` is faster, and as a result, for a given state of the RNG, |
| 183 | + the corresponding generated numbers have changed ([#33721]). |
| 184 | +* A new faster algorithm ("nearly division less") is used for generating random numbers |
| 185 | + within a range ([#29240]). As a result, the streams of generated numbers are changed |
| 186 | + (for ranges, like in `rand(1:9)`, and for collections in general, like in `rand([1, 2, 3])`). |
| 187 | + Also, for performance, the undocumented property that, given a seed and `a, b` of type `Int`, |
| 188 | + `rand(a:b)` produces the same stream on 32 and 64 bits architectures, is dropped. |
| 189 | + |
| 190 | +#### REPL |
| 191 | + |
| 192 | + |
| 193 | +#### SparseArrays |
| 194 | + |
| 195 | +* `lu!` accepts `UmfpackLU` as an argument to make use of its symbolic factorization. |
| 196 | +* The `trim` keyword argument for the functions `fkeep!`, `tril!`, `triu!`, |
| 197 | + `droptol!`,`dropzeros!` and `dropzeros` has been removed in favour of always |
| 198 | + trimming. Calling these with `trim=false` could result in invalid sparse |
| 199 | + arrays. |
| 200 | + |
| 201 | +#### Dates |
| 202 | + |
| 203 | +* The `eps` function now accepts `TimeType` types ([#31487]). |
| 204 | +* The `zero` function now accepts `TimeType` types ([#35554]). |
| 205 | + |
| 206 | +#### Statistics |
| 207 | + |
| 208 | + |
| 209 | +#### Sockets |
| 210 | + |
| 211 | +* Joining and leaving UDP multicast groups on a `UDPSocket` is now supported |
| 212 | + through `join_multicast_group()` and `leave_multicast_group()` ([#35521]). |
| 213 | + |
| 214 | +#### Distributed |
| 215 | + |
| 216 | +* `launch_on_machine` now supports and parses ipv6 square-bracket notation ([#34430]). |
| 217 | + |
| 218 | +Deprecated or removed |
| 219 | +--------------------- |
| 220 | + |
| 221 | +External dependencies |
| 222 | +--------------------- |
| 223 | + |
| 224 | +* OpenBLAS has been updated to v0.3.9 ([#35113]). |
| 225 | + |
| 226 | +Tooling Improvements |
| 227 | +--------------------- |
| 228 | + |
| 229 | + |
| 230 | +<!--- generated by NEWS-update.jl: --> |
| 231 | +[#25930]: https://github.com/JuliaLang/julia/issues/25930 |
| 232 | +[#26872]: https://github.com/JuliaLang/julia/issues/26872 |
| 233 | +[#28789]: https://github.com/JuliaLang/julia/issues/28789 |
| 234 | +[#29240]: https://github.com/JuliaLang/julia/issues/29240 |
| 235 | +[#29333]: https://github.com/JuliaLang/julia/issues/29333 |
| 236 | +[#29411]: https://github.com/JuliaLang/julia/issues/29411 |
| 237 | +[#29927]: https://github.com/JuliaLang/julia/issues/29927 |
| 238 | +[#30115]: https://github.com/JuliaLang/julia/issues/30115 |
| 239 | +[#31149]: https://github.com/JuliaLang/julia/issues/31149 |
| 240 | +[#31487]: https://github.com/JuliaLang/julia/issues/31487 |
| 241 | +[#32305]: https://github.com/JuliaLang/julia/issues/32305 |
| 242 | +[#32348]: https://github.com/JuliaLang/julia/issues/32348 |
| 243 | +[#32748]: https://github.com/JuliaLang/julia/issues/32748 |
| 244 | +[#33193]: https://github.com/JuliaLang/julia/issues/33193 |
| 245 | +[#33721]: https://github.com/JuliaLang/julia/issues/33721 |
| 246 | +[#33864]: https://github.com/JuliaLang/julia/issues/33864 |
| 247 | +[#33886]: https://github.com/JuliaLang/julia/issues/33886 |
| 248 | +[#33937]: https://github.com/JuliaLang/julia/issues/33937 |
| 249 | +[#34149]: https://github.com/JuliaLang/julia/issues/34149 |
| 250 | +[#34199]: https://github.com/JuliaLang/julia/issues/34199 |
| 251 | +[#34200]: https://github.com/JuliaLang/julia/issues/34200 |
| 252 | +[#34211]: https://github.com/JuliaLang/julia/issues/34211 |
| 253 | +[#34239]: https://github.com/JuliaLang/julia/issues/34239 |
| 254 | +[#34272]: https://github.com/JuliaLang/julia/issues/34272 |
| 255 | +[#34296]: https://github.com/JuliaLang/julia/issues/34296 |
| 256 | +[#34320]: https://github.com/JuliaLang/julia/issues/34320 |
| 257 | +[#34347]: https://github.com/JuliaLang/julia/issues/34347 |
| 258 | +[#34350]: https://github.com/JuliaLang/julia/issues/34350 |
| 259 | +[#34419]: https://github.com/JuliaLang/julia/issues/34419 |
| 260 | +[#34427]: https://github.com/JuliaLang/julia/issues/34427 |
| 261 | +[#34430]: https://github.com/JuliaLang/julia/issues/34430 |
| 262 | +[#34498]: https://github.com/JuliaLang/julia/issues/34498 |
| 263 | +[#34524]: https://github.com/JuliaLang/julia/issues/34524 |
| 264 | +[#34548]: https://github.com/JuliaLang/julia/issues/34548 |
| 265 | +[#34595]: https://github.com/JuliaLang/julia/issues/34595 |
| 266 | +[#34634]: https://github.com/JuliaLang/julia/issues/34634 |
| 267 | +[#34652]: https://github.com/JuliaLang/julia/issues/34652 |
| 268 | +[#34654]: https://github.com/JuliaLang/julia/issues/34654 |
| 269 | +[#34656]: https://github.com/JuliaLang/julia/issues/34656 |
| 270 | +[#34722]: https://github.com/JuliaLang/julia/issues/34722 |
| 271 | +[#34791]: https://github.com/JuliaLang/julia/issues/34791 |
| 272 | +[#34896]: https://github.com/JuliaLang/julia/issues/34896 |
| 273 | +[#34953]: https://github.com/JuliaLang/julia/issues/34953 |
| 274 | +[#35001]: https://github.com/JuliaLang/julia/issues/35001 |
| 275 | +[#35078]: https://github.com/JuliaLang/julia/issues/35078 |
| 276 | +[#35094]: https://github.com/JuliaLang/julia/issues/35094 |
| 277 | +[#35108]: https://github.com/JuliaLang/julia/issues/35108 |
| 278 | +[#35124]: https://github.com/JuliaLang/julia/issues/35124 |
| 279 | +[#35132]: https://github.com/JuliaLang/julia/issues/35132 |
| 280 | +[#35138]: https://github.com/JuliaLang/julia/issues/35138 |
| 281 | +[#35282]: https://github.com/JuliaLang/julia/issues/35282 |
| 282 | +[#35283]: https://github.com/JuliaLang/julia/issues/35283 |
| 283 | +[#35289]: https://github.com/JuliaLang/julia/issues/35289 |
| 284 | +[#35303]: https://github.com/JuliaLang/julia/issues/35303 |
| 285 | +[#35362]: https://github.com/JuliaLang/julia/issues/35362 |
| 286 | +[#35426]: https://github.com/JuliaLang/julia/issues/35426 |
| 287 | +[#35513]: https://github.com/JuliaLang/julia/issues/35513 |
| 288 | +[#35521]: https://github.com/JuliaLang/julia/issues/35521 |
| 289 | +[#35522]: https://github.com/JuliaLang/julia/issues/35522 |
| 290 | +[#35554]: https://github.com/JuliaLang/julia/issues/35554 |
| 291 | +[#35626]: https://github.com/JuliaLang/julia/issues/35626 |
| 292 | + |
1 | 293 | Julia v1.4 Release Notes
|
2 | 294 | ========================
|
3 | 295 |
|
|
0 commit comments