diff --git a/NEWS.md b/NEWS.md index d985ed677eff8..b96a6f1f6568d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -55,18 +55,19 @@ Language changes Instead of adding methods to `call`, methods are added by type using the syntax `(::ftype)(...) = ...`. `call` is deprecated ([#13412]). - * `using` and `import` are now case-sensitive even on case-insensitive filesystems (common on Mac and Windows) ([#13542]). + * `using` and `import` are now case-sensitive even on case-insensitive filesystems + (common on Mac and Windows) ([#13542]). * Relational symbols are now allowed as infix operators ([#8036]). - * A warning is always given when a method is overwritten (previously, this was done only when the new - and old definitions were in separate modules) ([#14759]). + * A warning is always given when a method is overwritten (previously, this was done + only when the new and old definitions were in separate modules) ([#14759]). - * `A <: B` is parsed as `Expr(:(<:), :A, :B)` in all cases ([#9503]). This also applies to the - `>:` operator. + * `A <: B` is parsed as `Expr(:(<:), :A, :B)` in all cases ([#9503]). + This also applies to the `>:` operator. * Simple 2-argument comparisons like `A < B` are parsed as calls instead of using the - `:comparison` expression type. + `:comparison` expression type ([#15524]). * The `if` keyword cannot be followed immediately by a line break ([#15763]). @@ -74,7 +75,7 @@ Language changes implemented internally as `Tuple{Vararg{T,N}}` ([#11242]). * Array comprehensions preserve the dimensions of the input ranges. For example, - `[ 2x for x in A]` will have the same dimensions as `A`. + `[2x for x in A]` will have the same dimensions as `A` ([#16622]). * The result type of an array comprehension depends only on the types of elements computed, instead of using type inference ([#7258]). If the result is empty, then @@ -98,7 +99,7 @@ Breaking changes * `pmap` keyword arguments `err_retry=true` and `err_stop=false` are deprecated. Action to be taken on errors can be specified via the `on_error` keyword argument. - Retry is specified via `retry_n`, `retry_on` and `retry_max_delay`. + Retry is specified via `retry_n`, `retry_on` and `retry_max_delay` ([#15409], [#15975], [#16663]). * `reshape` is now defined to always share data with the original array. If a reshaped copy is needed, use `copy(reshape(a))` or `copy!` to a new array of @@ -172,7 +173,8 @@ Library improvements * All dimensions indexed by scalars are now dropped, whereas previously only trailing scalar dimensions would be omitted from the result ([#13612]). - * Dimensions indexed by multidimensional arrays add dimensions. More generally, the dimensionality of the result is the sum of the dimensionalities of the indices ([#15431]). + * Dimensions indexed by multidimensional arrays add dimensions. More generally, the + dimensionality of the result is the sum of the dimensionalities of the indices ([#15431]). * New `normalize` and `normalize!` convenience functions for normalizing vectors ([#13681]). @@ -189,13 +191,13 @@ Library improvements vector instead of a one-column sparse matrix. ([#13440]) * Rank one update and downdate functions, `lowrankupdate`, `lowrankupdate!`, `lowrankdowndate`, - and `lowrankdowndate!`, for dense Cholesky factorizations ([#14243], [#14424]) + and `lowrankdowndate!`, for dense Cholesky factorizations ([#14243], [#14424]) * All `sparse` methods now retain provided numerical zeros as structural nonzeros; to drop numerical zeros, use `dropzeros!` ([#14798], [#15242]). * New `foreach` function for calling a function on every element of a collection when - the results are not needed. + the results are not needed ([#13774]). * `Cmd(cmd; ...)` now accepts new Windows-specific options `windows_verbatim` (to alter Windows command-line generation) and `windows_hide` (to @@ -217,10 +219,11 @@ Library improvements directory, instead of the private `/lib/julia` directory ([#16362]). * System reflection is now more consistently exposed from Sys and not Base. - `OS_NAME` has been replaced by `Sys.KERNEL` and always reports the name of the kernel (as reported by `uname`). - The `@windows_only` and `@osx` family of macros have been replaced with functions such as `is_windows()` and - or `is_apple()`. There's now also an `@static` macro that will evaluate the condition of an if-statement at - compile time, for when a static branch is required ([#16219]). + `OS_NAME` has been replaced by `Sys.KERNEL` and always reports the name of the + kernel (as reported by `uname`). The `@windows_only` and `@osx` family of macros + have been replaced with functions such as `is_windows()` and `is_apple()`. + There's now also an `@static` macro that will evaluate the condition of an + if-statement at compile time, for when a static branch is required ([#16219]). * Prime number related functions have been moved from `Base` to the [Primes.jl package](https://github.com/JuliaMath/Primes.jl) ([#16481]). @@ -247,7 +250,8 @@ Deprecated or removed * Deprecate `chol(A,Val{:U/:L})` in favor of `chol(A)` ([#13680]). - * `issym` is deprecated in favor of `issymmetric` to match similar functions (`ishermitian`, ...) ([#15192]) + * `issym` is deprecated in favor of `issymmetric` to match similar functions + (`ishermitian`, ...) ([#15192]) * `scale` is deprecated in favor of either `α*A`, `Diagonal(x)*A`, or `A*Diagonal(x)`. ([#15258]) @@ -289,6 +293,7 @@ Deprecated or removed [#13612]: https://github.com/JuliaLang/julia/issues/13612 [#13680]: https://github.com/JuliaLang/julia/issues/13680 [#13681]: https://github.com/JuliaLang/julia/issues/13681 +[#13774]: https://github.com/JuliaLang/julia/issues/13774 [#13780]: https://github.com/JuliaLang/julia/issues/13780 [#13824]: https://github.com/JuliaLang/julia/issues/13824 [#13897]: https://github.com/JuliaLang/julia/issues/13897 @@ -307,11 +312,14 @@ Deprecated or removed [#15242]: https://github.com/JuliaLang/julia/issues/15242 [#15244]: https://github.com/JuliaLang/julia/issues/15244 [#15258]: https://github.com/JuliaLang/julia/issues/15258 +[#15409]: https://github.com/JuliaLang/julia/issues/15409 [#15431]: https://github.com/JuliaLang/julia/issues/15431 +[#15524]: https://github.com/JuliaLang/julia/issues/15524 [#15550]: https://github.com/JuliaLang/julia/issues/15550 [#15609]: https://github.com/JuliaLang/julia/issues/15609 [#15731]: https://github.com/JuliaLang/julia/issues/15731 [#15763]: https://github.com/JuliaLang/julia/issues/15763 +[#15975]: https://github.com/JuliaLang/julia/issues/15975 [#16058]: https://github.com/JuliaLang/julia/issues/16058 [#16107]: https://github.com/JuliaLang/julia/issues/16107 [#16219]: https://github.com/JuliaLang/julia/issues/16219 @@ -322,7 +330,9 @@ Deprecated or removed [#16455]: https://github.com/JuliaLang/julia/issues/16455 [#16481]: https://github.com/JuliaLang/julia/issues/16481 [#16621]: https://github.com/JuliaLang/julia/issues/16621 +[#16622]: https://github.com/JuliaLang/julia/issues/16622 [#16645]: https://github.com/JuliaLang/julia/issues/16645 +[#16663]: https://github.com/JuliaLang/julia/issues/16663 [#16731]: https://github.com/JuliaLang/julia/issues/16731 [#16972]: https://github.com/JuliaLang/julia/issues/16972 [#17037]: https://github.com/JuliaLang/julia/issues/17037 diff --git a/base/clusterserialize.jl b/base/clusterserialize.jl index 11d6b1849afa6..f8505ca9b7ae5 100644 --- a/base/clusterserialize.jl +++ b/base/clusterserialize.jl @@ -1,4 +1,5 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license + import .Serializer: known_object_data, object_number, serialize_cycle, deserialize_cycle, writetag, __deserialized_types__, serialize_typename_body, deserialize_typename_body, TYPENAME_TAG, object_numbers diff --git a/base/dates/rounding.jl b/base/dates/rounding.jl index e9a08c6fc13c2..576ad44fe7fc9 100644 --- a/base/dates/rounding.jl +++ b/base/dates/rounding.jl @@ -1,3 +1,5 @@ +# This file is a part of Julia. License is MIT: http://julialang.org/license + # The epochs used for date rounding are based ISO 8601's "year zero" notation const DATEEPOCH = value(Date(0)) const DATETIMEEPOCH = value(DateTime(0)) diff --git a/base/docs/helpdb/Base.jl b/base/docs/helpdb/Base.jl index 772d67fed80c4..698602b5f1854 100644 --- a/base/docs/helpdb/Base.jl +++ b/base/docs/helpdb/Base.jl @@ -1455,9 +1455,9 @@ current `include` path but does not use it to search for files (see help for `in This function is typically used to load library code, and is implicitly called by `using` to load packages. -When searching for files, `require` first looks for package code under `Pkg.dir()`, then tries -paths in the global array `LOAD_PATH`. `require` is case-sensitive on all -platforms including those with case-insensitive filesystems like macOS and +When searching for files, `require` first looks for package code under `Pkg.dir()`, +then tries paths in the global array `LOAD_PATH`. `require` is case-sensitive on +all platforms, including those with case-insensitive filesystems like macOS and Windows. """ require @@ -4080,7 +4080,7 @@ rand Convert an integer to a string in the given base, optionally specifying a number of digits to pad to. """ -base(base, n, pad) +base """ BoundsError([a],[i]) diff --git a/base/exports.jl b/base/exports.jl index 7f9605c9ee9bc..2e83da356f2b2 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -1216,7 +1216,6 @@ export TextDisplay, istextmime, MIME, - @MIME, @MIME_str, reprmime, stringmime, diff --git a/base/linalg/factorization.jl b/base/linalg/factorization.jl index 49254d2638dc1..2a2340e4c1f0c 100644 --- a/base/linalg/factorization.jl +++ b/base/linalg/factorization.jl @@ -51,7 +51,7 @@ end """ A_ldiv_B!([Y,] A, B) -> Y -Compute `A \ B` in-place and store the result in `Y`, returning the result. +Compute `A \\ B` in-place and store the result in `Y`, returning the result. If only two arguments are passed, then `A_ldiv_B!(A, B)` overwrites `B` with the result. diff --git a/base/range.jl b/base/range.jl index 335f2d89cb7d1..2c819e05c5e40 100644 --- a/base/range.jl +++ b/base/range.jl @@ -661,7 +661,7 @@ end -(r::FloatRange) = FloatRange(-r.start, -r.step, r.len, r.divisor) -(r::LinSpace) = LinSpace(-r.start, -r.stop, r.len, r.divisor) -.+(x::Real, r::AbstractUnitRange) = range(x + first(r), length(r)) +.+(x::Real, r::AbstractUnitRange) = range(x + first(r), length(r)) .+(x::Real, r::Range) = (x+first(r)):step(r):(x+last(r)) #.+(x::Real, r::StepRange) = range(x + r.start, r.step, length(r)) .+(x::Real, r::FloatRange) = FloatRange(r.divisor*x + r.start, r.step, r.len, r.divisor) @@ -678,7 +678,7 @@ function .-(x::Real, r::LinSpace) x2 = x * r.divisor / (r.len - 1) LinSpace(x2 - r.start, x2 - r.stop, r.len, r.divisor) end -.-(r::AbstractUnitRange, x::Real) = range(first(r)-x, length(r)) +.-(r::AbstractUnitRange, x::Real) = range(first(r)-x, length(r)) .-(r::StepRange , x::Real) = range(r.start-x, r.step, length(r)) .-(r::FloatRange, x::Real) = FloatRange(r.start - r.divisor*x, r.step, r.len, r.divisor) function .-(r::LinSpace, x::Real) diff --git a/base/sharedarray.jl b/base/sharedarray.jl index 894c9eb7358b5..9b527f9a1b4e6 100644 --- a/base/sharedarray.jl +++ b/base/sharedarray.jl @@ -1,4 +1,5 @@ # This file is a part of Julia. License is MIT: http://julialang.org/license + import .Serializer: serialize_cycle, serialize_type, writetag, UNDEFREF_TAG type SharedArray{T,N} <: DenseArray{T,N} diff --git a/contrib/add_license_to_files.jl b/contrib/add_license_to_files.jl index 3ee803b132035..1ded19a34f31b 100644 --- a/contrib/add_license_to_files.jl +++ b/contrib/add_license_to_files.jl @@ -43,6 +43,8 @@ const skipfiles = [ "../src/abi_x86.cpp", "../src/abi_x86_64.cpp", "../src/disasm.cpp", + "../src/getopt.c", + "../src/getopt.h", "../src/support/END.h", "../src/support/ENTRY.amd64.h", "../src/support/ENTRY.i387.h", @@ -54,6 +56,7 @@ const skipfiles = [ "../src/support/strtod.c", "../src/support/tzfile.h", "../src/support/utf8.c", + "../test/perf/micro/randmtzig.c", ] const ext_prefix = Dict([ diff --git a/doc/devdocs/ast.rst b/doc/devdocs/ast.rst index d2699c0428d62..72f1ca4774a36 100644 --- a/doc/devdocs/ast.rst +++ b/doc/devdocs/ast.rst @@ -135,14 +135,6 @@ These symbols appear in the ``head`` field of ``Expr``\s in lowered form. ``null`` has no arguments; simply yields the value ``nothing`` -``static_typeof`` - a horrible misfeature used to determine the result type of array - comprehensions. Planned to be removed. - -``type_goto`` - a virtual control flow edge used to convey type data to ``static_typeof``, - also to be removed. - ``new`` allocates a new struct-like object. First argument is the type. The ``new`` pseudo-function is lowered to this, and the type is always inserted by the diff --git a/doc/manual/dates.rst b/doc/manual/dates.rst index 08b5ba148b228..e23df78283255 100644 --- a/doc/manual/dates.rst +++ b/doc/manual/dates.rst @@ -389,7 +389,7 @@ default, the :class:`TimeType` :func:`round` method uses the ``RoundNearestTiesU rounding mode. (It's difficult to guess what breaking ties to nearest "even" :class:`TimeType` would entail.) Further details on the available ``RoundingMode`` s can be found in the -`API reference `_. +`API reference `_. Rounding should generally behave as expected, but there are a few cases in which the expected behaviour is not obvious. diff --git a/doc/manual/noteworthy-differences.rst b/doc/manual/noteworthy-differences.rst index f5c539393266d..27ac14abfe3de 100644 --- a/doc/manual/noteworthy-differences.rst +++ b/doc/manual/noteworthy-differences.rst @@ -103,7 +103,7 @@ some noteworthy differences that may trip up Julia users accustomed to MATLAB: - In MATLAB, an idiomatic way to remove unwanted values is to use logical indexing, like in the expression ``x(x>3)`` or in the statement ``x(x>3) = []`` to modify ``x`` in-place. In contrast, Julia provides the - higher order functions :func:`filter` and a :func:`filter!`, allowing users + higher order functions :func:`filter` and :func:`filter!`, allowing users to write ``filter(z->z>3, x)`` and ``filter!(z->z>3, x)`` as alternatives to the corresponding transliterations ``x[x.>3]`` and ``x = x[x.>3]``. Using :func:`filter!` reduces the use of temporary arrays. @@ -235,7 +235,7 @@ noteworthy differences: - In R, an idiomatic way to remove unwanted values is to use logical indexing, like in the expression ``x[x>3]`` or in the statement ``x = x[x>3]`` to modify ``x`` in-place. In contrast, Julia provides the higher order functions - :func:`filter` and a :func:`filter!`, allowing users to write + :func:`filter` and :func:`filter!`, allowing users to write ``filter(z->z>3, x)`` and ``filter!(z->z>3, x)`` as alternatives to the corresponding transliterations ``x[x.>3]`` and ``x = x[x.>3]``. Using :func:`filter!` reduces the use of temporary arrays. diff --git a/doc/manual/performance-tips.rst b/doc/manual/performance-tips.rst index 2c88ae20a0703..eb092420787bc 100644 --- a/doc/manual/performance-tips.rst +++ b/doc/manual/performance-tips.rst @@ -947,51 +947,6 @@ Taken to its extreme, pre-allocation can make your code uglier, so performance measurements and some judgment may be required. -Use parentheses in long arithmetic operations ---------------------------------------------- - -If your code has a long arithmetic operation involving ``+`` or ``*`` operators, -then consider using parentheses to chain up to four or five operations together. -This is to avoid the splatting penalty from a longer list of arguments to function -return statement. - -Without parentheses: - - const k = zeros(20) - function test_mem() - return k[1] + k[2] + k[3] + k[4] + k[5] + 2.0 * k[6] + k[7] + k[8] + k[9] + k[10] - end - - function test(n::Int64) - ret = 0.0 - for i = 1:n - ret += test_mem() - end - ret - end - @time test(100000000) - - 5.017971 seconds (900.00 M allocations: 13.411 GB, 15.04% gc time) - -With: - - const k = zeros(20) - function test_mem() - return (k[1] + k[2] + k[3] + k[4] + k[5]) + 2.0 * k[6] + k[7] + k[8] + k[9] + k[10] - end - - function test(n::Int64) - ret = 0.0 - for i = 1:n - ret += test_mem() - end - ret - end - @time test(100000000) - - 0.302478 seconds (5.26 k allocations: 248.985 KB) - - Avoid string interpolation for I/O ---------------------------------- diff --git a/doc/stdlib/base.rst b/doc/stdlib/base.rst index 320539cabed42..31d8e48433e1b 100644 --- a/doc/stdlib/base.rst +++ b/doc/stdlib/base.rst @@ -126,7 +126,7 @@ Getting Around Loads a source files, in the context of the ``Main`` module, on every active node, searching standard locations for files. ``require`` is considered a top-level operation, so it sets the current ``include`` path but does not use it to search for files (see help for ``include``\ ). This function is typically used to load library code, and is implicitly called by ``using`` to load packages. - When searching for files, ``require`` first looks for package code under ``Pkg.dir()``\ , then tries paths in the global array ``LOAD_PATH``\ . ``require`` is case-sensitive on all platforms including those with case-insensitive filesystems like macOS and Windows. + When searching for files, ``require`` first looks for package code under ``Pkg.dir()``\ , then tries paths in the global array ``LOAD_PATH``\ . ``require`` is case-sensitive on all platforms, including those with case-insensitive filesystems like macOS and Windows. .. function:: Base.compilecache(module::String) diff --git a/doc/stdlib/linalg.rst b/doc/stdlib/linalg.rst index 0cdf61ae0e7a3..c671d355c2775 100644 --- a/doc/stdlib/linalg.rst +++ b/doc/stdlib/linalg.rst @@ -1473,7 +1473,7 @@ according to the usual Julia convention. .. Docstring generated from Julia source - Compute ``A B`` in-place and store the result in ``Y``\ , returning the result. If only two arguments are passed, then ``A_ldiv_B!(A, B)`` overwrites ``B`` with the result. + Compute ``A \ B`` in-place and store the result in ``Y``\ , returning the result. If only two arguments are passed, then ``A_ldiv_B!(A, B)`` overwrites ``B`` with the result. The argument ``A`` should *not* be a matrix. Rather, instead of matrices it should be a factorization object (e.g. produced by :func:`factorize` or :func:`cholfact`\ ). The reason for this is that factorization itself is both expensive and typically allocates memory (although it can also be done in-place via, e.g., :func:`lufact!`\ ), and performance-critical situations requiring ``A_ldiv_B!`` usually also require fine-grained control over the factorization of ``A``\ . diff --git a/src/common_symbols2.inc b/src/common_symbols2.inc index 8a0874f720585..a53732df4e3bb 100644 --- a/src/common_symbols2.inc +++ b/src/common_symbols2.inc @@ -70,11 +70,9 @@ jl_symbol("#print_to_string#138"), jl_symbol("Main"), jl_symbol("pointer.jl"), jl_symbol("DimensionMismatch"), -jl_symbol("type_goto"), jl_symbol("stride"), jl_symbol("uP"), jl_symbol("III"), -jl_symbol("static_typeof"), jl_symbol("uW"), jl_symbol("checked_trunc_uint"), jl_symbol("sparse/sparsematrix.jl"), diff --git a/src/dump.c b/src/dump.c index 4ceb59fde78b8..c6dd9176ea905 100644 --- a/src/dump.c +++ b/src/dump.c @@ -556,10 +556,10 @@ static void jl_serialize_datatype(ios_t *s, jl_datatype_t *dt) } write_int32(s, dt->size); - int has_instance = !!(dt->instance != NULL); - int has_layout = !!(dt->layout != NULL); + int has_instance = (dt->instance != NULL); + int has_layout = (dt->layout != NULL); write_uint8(s, dt->abstract | (dt->mutabl<<1) | (has_layout<<2) | (has_instance<<3) | - (dt->hastypevars<<4) | (dt->haswildcard<<5) | (dt->isleaftype<<6)); + (dt->hastypevars<<4) | (dt->haswildcard<<5) | (dt->isleaftype<<6)); write_int32(s, dt->depth); if (!dt->abstract) { write_uint16(s, dt->ninitialized); diff --git a/src/jloptions.c b/src/jloptions.c index 6265e100b3afe..ab91b109a3cb5 100644 --- a/src/jloptions.c +++ b/src/jloptions.c @@ -1,3 +1,5 @@ +// This file is a part of Julia. License is MIT: http://julialang.org/license + #include #include "julia.h" diff --git a/src/toplevel.c b/src/toplevel.c index 23db71a5e0fb6..5a0a7a682a333 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -103,7 +103,7 @@ static void jl_module_load_time_initialize(jl_module_t *m) jl_module_init_order = jl_alloc_vec_any(0); jl_array_ptr_1d_push(jl_module_init_order, (jl_value_t*)m); jl_function_t *f = jl_module_get_initializer(m); - if (f != NULL) { + if (f != NULL) { jl_value_t *tt = jl_is_type(f) ? (jl_value_t*)jl_wrap_Type(f) : jl_typeof(f); JL_GC_PUSH1(&tt); tt = (jl_value_t*)jl_apply_tuple_type_v(&tt, 1); diff --git a/test/cartesian.jl b/test/cartesian.jl index 907905aff13b3..3180a4f4dccfc 100644 --- a/test/cartesian.jl +++ b/test/cartesian.jl @@ -1,3 +1,5 @@ +# This file is a part of Julia. License is MIT: http://julialang.org/license + @test Base.Cartesian.exprresolve(:(1 + 3)) == 4 ex = Base.Cartesian.exprresolve(:(if 5 > 4; :x; else :y; end)) @test ex.args[2] == QuoteNode(:x) diff --git a/test/ccall.jl b/test/ccall.jl index 8600a305ae177..7f0792a87fdd5 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -845,7 +845,7 @@ elseif Sys.ARCH === :powerpc64le || Sys.ARCH === :ppc64le (14, 13, 12, 11), (15, 14, 13, 12), (16, 15, 14, 13), (17, 16, 15, 14), (18, 17, 16, 15), (1024, 1023, 1022, 1021), (1025, 1024, 1023, 1022), (1026, 1025, 1024, 1023), (1027, 1026, 1025, 1024), (10028, 10027, 10026, 10025)) -else +elseif Sys.ARCH !== :i686 && Sys.ARCH !== :arm # TODO warn("ccall: no VecReg tests run for this platform") end diff --git a/test/dates/rounding.jl b/test/dates/rounding.jl index 80218fcf0db47..1d6ec265b80ed 100644 --- a/test/dates/rounding.jl +++ b/test/dates/rounding.jl @@ -1,3 +1,5 @@ +# This file is a part of Julia. License is MIT: http://julialang.org/license + # Test conversion to and from the rounding epoch (ISO 8601 year 0000) @test Dates.epochdays2date(-1) == Dates.Date(-1, 12, 31) @test Dates.epochdays2date(0) == Dates.Date(0, 1, 1) diff --git a/ui/repl.c b/ui/repl.c index db0cacf84fbd3..b0ae9c03c1ccd 100644 --- a/ui/repl.c +++ b/ui/repl.c @@ -223,7 +223,7 @@ int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) } #endif libsupport_init(); - if (argc >= 2 && strcmp(argv[1],"--lisp") == 0) { + if (argc >= 2 && strcmp((char*)argv[1],"--lisp") == 0) { jl_lisp_prompt(); return 0; }