From 2c3d9471f9b3fd29eef6605288fefd20369585ec Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 6 Jun 2017 13:30:30 -0400 Subject: [PATCH] remove Operators module --- NEWS.md | 3 ++ base/dates/Dates.jl | 2 +- base/dates/periods.jl | 1 - base/deprecated.jl | 13 ++++++ base/exports.jl | 1 - base/grisu/float.jl | 2 + base/grisu/grisu.jl | 2 - base/multidimensional.jl | 2 +- base/operators.jl | 71 ------------------------------- base/pkg/resolve/fieldvalue.jl | 1 - base/pkg/resolve/versionweight.jl | 2 - base/sysimg.jl | 1 - doc/src/manual/functions.md | 3 -- 13 files changed, 20 insertions(+), 84 deletions(-) diff --git a/NEWS.md b/NEWS.md index cff38eca2c720..015fdf1457670 100644 --- a/NEWS.md +++ b/NEWS.md @@ -92,6 +92,9 @@ Deprecated or removed which now require a module argument. And it caused the bugfix of other default arguments to use the Main module (including `whos`, `which`). + * The `Operators` module is deprecated. Instead, import required operators explicitly + from `Base`, e.g. `import Base: +, -, *, /` ([#22251]). + Julia v0.6.0 Release Notes ========================== diff --git a/base/dates/Dates.jl b/base/dates/Dates.jl index b2551e94784d1..44ed2aefa7972 100644 --- a/base/dates/Dates.jl +++ b/base/dates/Dates.jl @@ -32,7 +32,7 @@ for more information. """ module Dates -importall ..Base.Operators +import ..Base: ==, div, fld, mod, rem, gcd, lcm, +, -, *, /, % import ..Base.broadcast using Base.Iterators diff --git a/base/dates/periods.jl b/base/dates/periods.jl index 76754a4e67d10..628e077b1aec8 100644 --- a/base/dates/periods.jl +++ b/base/dates/periods.jl @@ -65,7 +65,6 @@ Base.isless(x::P, y::P) where {P<:Period} = isless(value(x), value(y)) Base.isless(x::Period, y::Period) = isless(promote(x, y)...) # Period Arithmetic, grouped by dimensionality: -import Base: div, fld, mod, rem, gcd, lcm, +, -, *, /, % for op in (:+, :-, :lcm, :gcd) @eval ($op)(x::P, y::P) where {P<:Period} = P(($op)(value(x), value(y))) end diff --git a/base/deprecated.jl b/base/deprecated.jl index 4defa517f7c34..f600006bddc47 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1421,6 +1421,19 @@ function LibGit2.set_remote_url(path::AbstractString, url::AbstractString; remot LibGit2.set_remote_url(path, remote, url) end +module Operators + for op in [:!, :(!=), :(!==), :%, :&, :*, :+, :-, :/, ://, :<, :<:, :<<, :(<=), + :<|, :(==), :(===), :>, :>:, :(>=), :>>, :>>>, :\, :^, :colon, + :ctranspose, :getindex, :hcat, :hvcat, :setindex!, :transpose, :vcat, + :xor, :|, :|>, :~, :×, :÷, :∈, :∉, :∋, :∌, :∘, :√, :∛, :∩, :∪, :≠, :≤, + :≥, :⊆, :⊈, :⊊, :⊻, :⋅] + if isdefined(Base, op) + @eval Base.@deprecate_binding $op Base.$op + end + end +end +export Operators + # END 0.7 deprecations # BEGIN 1.0 deprecations diff --git a/base/exports.jl b/base/exports.jl index d88133ca324d7..52866a9014705 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -4,7 +4,6 @@ export # Modules FFTW, Meta, - Operators, Pkg, LibGit2, StackTraces, diff --git a/base/grisu/float.jl b/base/grisu/float.jl index af95f941dd10f..a92b94ccd4b51 100644 --- a/base/grisu/float.jl +++ b/base/grisu/float.jl @@ -28,6 +28,8 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +import Base: -, * + struct Float s::UInt64 e::Int32 diff --git a/base/grisu/grisu.jl b/base/grisu/grisu.jl index 40ddf401ce865..83f1f89365bf9 100644 --- a/base/grisu/grisu.jl +++ b/base/grisu/grisu.jl @@ -2,8 +2,6 @@ module Grisu -importall ..Base.Operators - export print_shortest export DIGITS, grisu diff --git a/base/multidimensional.jl b/base/multidimensional.jl index a5dfd377fbad6..ebe78615ac392 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -6,7 +6,7 @@ module IteratorsMD setindex!, IndexStyle, min, max, zero, one, isless, eachindex, ndims, iteratorsize, convert - importall ..Base.Operators + import Base: +, -, * import Base: simd_outer_range, simd_inner_length, simd_index using Base: IndexLinear, IndexCartesian, AbstractCartesianIndex, fill_to_length, tail diff --git a/base/operators.jl b/base/operators.jl index fbb99958f67e9..bb347e3e41207 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -902,74 +902,3 @@ julia> filter(!isalpha, str) ``` """ !(f::Function) = (x...)->!f(x...) - -# some operators not defined yet -global //, >:, <|, hcat, hvcat, ⋅, ×, ∈, ∉, ∋, ∌, ⊆, ⊈, ⊊, ∩, ∪, √, ∛ - -this_module = @__MODULE__ -baremodule Operators - -export - !, - !=, - !==, - ===, - xor, - %, - ÷, - &, - *, - +, - -, - /, - //, - <, - <:, - >:, - <<, - <=, - ==, - >, - >=, - ≥, - ≤, - ≠, - >>, - >>>, - \, - ^, - |, - |>, - <|, - ~, - ⋅, - ×, - ∈, - ∉, - ∋, - ∌, - ⊆, - ⊈, - ⊊, - ∩, - ∪, - √, - ∛, - ⊻, - ∘, - colon, - hcat, - vcat, - hvcat, - getindex, - setindex!, - transpose, - ctranspose - -import ..this_module: !, !=, xor, %, ÷, &, *, +, -, - /, //, <, <:, <<, <=, ==, >, >=, >>, >>>, - <|, |>, \, ^, |, ~, !==, ===, >:, colon, hcat, vcat, hvcat, getindex, setindex!, - transpose, ctranspose, - ≥, ≤, ≠, ⋅, ×, ∈, ∉, ∋, ∌, ⊆, ⊈, ⊊, ∩, ∪, √, ∛, ⊻, ∘ - -end diff --git a/base/pkg/resolve/fieldvalue.jl b/base/pkg/resolve/fieldvalue.jl index 7831dce0ec56e..01549cd8ca4b9 100644 --- a/base/pkg/resolve/fieldvalue.jl +++ b/base/pkg/resolve/fieldvalue.jl @@ -3,7 +3,6 @@ module FieldValues using ...VersionWeights -importall .....Base.Operators export FieldValue, Field, validmax, secondmax diff --git a/base/pkg/resolve/versionweight.jl b/base/pkg/resolve/versionweight.jl index 596377c55bf9a..440483181c4c9 100644 --- a/base/pkg/resolve/versionweight.jl +++ b/base/pkg/resolve/versionweight.jl @@ -2,8 +2,6 @@ module VersionWeights -importall ....Base.Operators - export VersionWeight struct HierarchicalValue{T} diff --git a/base/sysimg.jl b/base/sysimg.jl index 5431dd9706392..280d26e4c16b3 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -447,6 +447,5 @@ include(Base, "precompile.jl") end # baremodule Base using Base -importall Base.Operators Base.isfile("userimg.jl") && Base.include(Main, "userimg.jl") diff --git a/doc/src/manual/functions.md b/doc/src/manual/functions.md index 1b7c86760fb29..c1832848f2061 100644 --- a/doc/src/manual/functions.md +++ b/doc/src/manual/functions.md @@ -169,9 +169,6 @@ A few special expressions correspond to calls to functions with non-obvious name | `A[i]` | [`getindex()`](@ref) | | `A[i]=x` | [`setindex!()`](@ref) | -These functions are included in the `Base.Operators` module even though they do not have operator-like -names. - ## [Anonymous Functions](@id man-anonymous-functions) Functions in Julia are [first-class objects](https://en.wikipedia.org/wiki/First-class_citizen):