diff --git a/NEWS.md b/NEWS.md index 6f8fb82d0cd5c..78f68636312b2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,7 @@ New language features * The `extrema` function now accepts a function argument in the same manner as `minimum` and `maximum` ([#30323]). * `hasmethod` can now check for matching keyword argument names ([#30712]). +* `startswith` and `endswith` now accept a `Regex` for the second argument ([#29790]). Multi-threading changes ----------------------- @@ -27,12 +28,13 @@ New library functions --------------------- * `getipaddrs()` function returns all the IP addresses of the local machine ([#30349]) +* Added `Base.hasproperty` and `Base.hasfield` ([#28850]). +* One argument `!=(x)`, `>(x)`, `>=(x)`, `<(x)`, `<=(x)` has been added for currying, + similar to the existing `==(x)` and `isequal(x)` methods ([#30915]). Standard library changes ------------------------ -* Added `Base.hasproperty` and `Base.hasfield` ([#28850]). - #### LinearAlgebra * Added keyword arguments `rtol`, `atol` to `pinv` and `nullspace` ([#29998]). @@ -68,8 +70,22 @@ Deprecated or removed +[#21598]: https://github.com/JuliaLang/julia/issues/21598 +[#24980]: https://github.com/JuliaLang/julia/issues/24980 +[#28850]: https://github.com/JuliaLang/julia/issues/28850 +[#29790]: https://github.com/JuliaLang/julia/issues/29790 [#29998]: https://github.com/JuliaLang/julia/issues/29998 [#30061]: https://github.com/JuliaLang/julia/issues/30061 [#30200]: https://github.com/JuliaLang/julia/issues/30200 +[#30298]: https://github.com/JuliaLang/julia/issues/30298 [#30323]: https://github.com/JuliaLang/julia/issues/30323 [#30349]: https://github.com/JuliaLang/julia/issues/30349 +[#30372]: https://github.com/JuliaLang/julia/issues/30372 +[#30583]: https://github.com/JuliaLang/julia/issues/30583 +[#30584]: https://github.com/JuliaLang/julia/issues/30584 +[#30593]: https://github.com/JuliaLang/julia/issues/30593 +[#30618]: https://github.com/JuliaLang/julia/issues/30618 +[#30670]: https://github.com/JuliaLang/julia/issues/30670 +[#30712]: https://github.com/JuliaLang/julia/issues/30712 +[#30724]: https://github.com/JuliaLang/julia/issues/30724 +[#30915]: https://github.com/JuliaLang/julia/issues/30915 diff --git a/base/operators.jl b/base/operators.jl index 55ad563eab2f8..802f6c38b9486 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -948,6 +948,9 @@ Create a function that compares its argument to `x` using [`!=`](@ref), i.e. a function equivalent to `y -> y != x`. The returned function is of type `Base.Fix2{typeof(!=)}`, which can be used to implement specialized methods. + +!!! compat "Julia 1.2" + This functionality requires at least Julia 1.2. """ !=(x) = Fix2(!=, x) @@ -958,6 +961,9 @@ Create a function that compares its argument to `x` using [`>=`](@ref), i.e. a function equivalent to `y -> y >= x`. The returned function is of type `Base.Fix2{typeof(>=)}`, which can be used to implement specialized methods. + +!!! compat "Julia 1.2" + This functionality requires at least Julia 1.2. """ >=(x) = Fix2(>=, x) @@ -968,6 +974,9 @@ Create a function that compares its argument to `x` using [`<=`](@ref), i.e. a function equivalent to `y -> y <= x`. The returned function is of type `Base.Fix2{typeof(<=)}`, which can be used to implement specialized methods. + +!!! compat "Julia 1.2" + This functionality requires at least Julia 1.2. """ <=(x) = Fix2(<=, x) @@ -978,6 +987,9 @@ Create a function that compares its argument to `x` using [`>`](@ref), i.e. a function equivalent to `y -> y > x`. The returned function is of type `Base.Fix2{typeof(>)}`, which can be used to implement specialized methods. + +!!! compat "Julia 1.2" + This functionality requires at least Julia 1.2. """ >(x) = Fix2(>, x) @@ -988,6 +1000,9 @@ Create a function that compares its argument to `x` using [`<`](@ref), i.e. a function equivalent to `y -> y < x`. The returned function is of type `Base.Fix2{typeof(<)}`, which can be used to implement specialized methods. + +!!! compat "Julia 1.2" + This functionality requires at least Julia 1.2. """ <(x) = Fix2(<, x) diff --git a/base/reflection.jl b/base/reflection.jl index 3f3339103b6e9..f366c467451ce 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -179,8 +179,10 @@ fieldnames(t::Type{<:Tuple}) = ntuple(identity, fieldcount(t)) """ hasfield(T::Type, name::Symbol) -Returns a boolean indicating whether DataType has the specified field as one of -its own fields. +Return a boolean indicating whether `T` has `name` as one of its own fields. + +!!! compat "Julia 1.2" + This function requires at least Julia 1.2. """ function hasfield(::Type{T}, name::Symbol) where T @_pure_meta @@ -1258,7 +1260,9 @@ propertynames(x, private) = propertynames(x) # ignore private flag by default """ hasproperty(x, s::Symbol) -Returns a boolean indicating whether the object `x` has the specified property as one of -its own properties. +Return a boolean indicating whether the object `x` has `s` as one of its own properties. + +!!! compat "Julia 1.2" + This function requires at least Julia 1.2. """ hasproperty(x, s::Symbol) = s in propertynames(x) diff --git a/base/regex.jl b/base/regex.jl index d952f1f6ba4b8..8462508108a2e 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -187,6 +187,9 @@ Return `true` if `s` starts with the regex pattern, `prefix`. See also [`occursin`](@ref) and [`endswith`](@ref). +!!! compat "Julia 1.2" + This method requires at least Julia 1.2. + # Examples ```jldoctest julia> startswith("JuliaLang", r"Julia|Romeo") @@ -218,6 +221,9 @@ Return `true` if `s` ends with the regex pattern, `suffix`. See also [`occursin`](@ref) and [`startswith`](@ref). +!!! compat "Julia 1.2" + This method requires at least Julia 1.2. + # Examples ```jldoctest julia> endswith("JuliaLang", r"Lang|Roberts") diff --git a/doc/src/base/base.md b/doc/src/base/base.md index 205a6708e5e43..3a1df621f1bff 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -122,6 +122,7 @@ Base.deepcopy Base.getproperty Base.setproperty! Base.propertynames +Base.hasproperty Core.getfield Core.setfield! Core.isdefined @@ -158,6 +159,7 @@ Base.isstructtype Base.nameof(::DataType) Base.fieldnames Base.fieldname +Base.hasfield ``` ### Memory layout