Skip to content

Commit

Permalink
remove default importall Base.Operators
Browse files Browse the repository at this point in the history
fixes #8113
  • Loading branch information
JeffBezanson committed Jul 28, 2015
1 parent 721bdbe commit 3bb7e2f
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 16 deletions.
2 changes: 2 additions & 0 deletions base/Dates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module Dates

importall ..Base.Operators

include("dates/types.jl")
include("dates/periods.jl")
include("dates/accessors.jl")
Expand Down
3 changes: 2 additions & 1 deletion base/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import Base:
Display,
display,
writemime,
AnyDict
AnyDict,
==

import ..LineEdit:
CompletionProvider,
Expand Down
3 changes: 1 addition & 2 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ using ..Cartesian
import Base.promote_eltype
import Base.@get!
import Base.num_bit_chunks, Base._msk_end, Base.unsafe_bitgetindex
import Base.(.+), Base.(.-), Base.(.*), Base.(./), Base.(.\), Base.(.//)
import Base.(.==), Base.(.<), Base.(.!=), Base.(.<=)
import Base: .+, .-, .*, ./, .\, .//, .==, .<, .!=, .<=, .%, .<<, .>>, .^
export broadcast, broadcast!, broadcast_function, broadcast!_function, bitbroadcast
export broadcast_getindex, broadcast_setindex!

Expand Down
2 changes: 2 additions & 0 deletions base/grisu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module Grisu

importall ..Base.Operators

export print_shortest
export DIGITS, grisu

Expand Down
2 changes: 2 additions & 0 deletions base/grisu/bignums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

module Bignums

import Base: ==, <

export Bignum

const kMaxSignificantBits = 3584
Expand Down
1 change: 1 addition & 0 deletions base/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module LinAlg

importall Base
importall ..Base.Operators
import Base: USE_BLAS64, size, copy, copy_transpose!, power_by_squaring,
print_matrix, transpose!, unsafe_getindex, unsafe_setindex!

Expand Down
2 changes: 1 addition & 1 deletion base/markdown/Markdown.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Markdown

import Base: writemime
import Base: writemime, ==

typealias String AbstractString

Expand Down
1 change: 1 addition & 0 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
module IteratorsMD

import Base: eltype, length, start, done, next, last, getindex, setindex!, linearindexing, min, max, eachindex, ndims
importall ..Base.Operators
import Base: simd_outer_range, simd_inner_length, simd_index, @generated
import Base: @nref, @ncall, @nif, @nexprs, LinearFast, LinearSlow, to_index

Expand Down
2 changes: 2 additions & 0 deletions base/pkg/reqs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module Reqs

import Base: ==

using ..Types

# representing lines of REQUIRE files
Expand Down
1 change: 1 addition & 0 deletions base/pkg/resolve/fieldvalue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module FieldValues

using ...VersionWeights
importall .....Base.Operators

export FieldValue, Field, validmax, secondmax

Expand Down
2 changes: 2 additions & 0 deletions base/pkg/resolve/versionweight.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module VersionWeights

importall ....Base.Operators

export VersionWeight

immutable HierarchicalValue{T}
Expand Down
2 changes: 1 addition & 1 deletion base/pkg/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Types

export VersionInterval, VersionSet, Requires, Available, Fixed, merge_requires!, satisfies
import Base: show, isempty, in, intersect, hash, deepcopy_internal
import Base: show, isempty, in, intersect, hash, deepcopy_internal, ==

immutable VersionInterval
lower::VersionNumber
Expand Down
1 change: 1 addition & 0 deletions base/sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using Base.Sort: Forward
using Base.LinAlg: AbstractTriangular

importall Base
importall ..Base.Operators
importall Base.LinAlg
import Base.promote_eltype
import Base.@get!
Expand Down
2 changes: 2 additions & 0 deletions base/sparse/spqr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module SPQR

import Base: \

# ordering options */
const ORDERING_FIXED = Int32(0)
const ORDERING_NATURAL = Int32(1)
Expand Down
13 changes: 6 additions & 7 deletions doc/manual/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,21 +160,20 @@ contain ``using Base``, since this is needed in the vast majority of cases.
Default top-level definitions and bare modules
----------------------------------------------

In addition to ``using Base``, all operators are explicitly imported,
since one typically wants to extend operators rather than creating entirely
new definitions of them. A module also automatically contains a definition
of the ``eval`` function, which evaluates expressions within the context of
that module.
In addition to ``using Base``, modules also perform ``import Base.call`` by
default, to facilitate adding constructors to new types.
A new module also automatically contains a definition of the ``eval`` function,
which evaluates expressions within the context of that module.

If these ``Base`` definitions are not wanted, modules can be defined using the
If these default definitions are not wanted, modules can be defined using the
keyword ``baremodule`` instead (note: ``Core`` is still imported, as per above).
In terms of ``baremodule``, a standard ``module`` looks like this::

baremodule Mod

using Base

importall Base.Operators
import Base.call

eval(x) = Core.eval(Mod, x)
eval(m,x) = Core.eval(m, x)
Expand Down
2 changes: 2 additions & 0 deletions examples/modint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module ModInts
export ModInt

import Base: +, -, *

immutable ModInt{n} <: Integer
k::Int
ModInt(k) = new(mod(k,n))
Expand Down
6 changes: 2 additions & 4 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ void jl_add_standard_imports(jl_module_t *m)
assert(jl_base_module != NULL);
// using Base
jl_module_using(m, jl_base_module);
// importall Base.Operators
jl_module_t *opmod = (jl_module_t*)jl_get_global(jl_base_module, jl_symbol("Operators"));
if (opmod != NULL)
jl_module_importall(m, opmod);
// import Base.call
jl_module_import(m, jl_base_module, jl_symbol("call"));
}

jl_module_t *jl_new_main_module(void)
Expand Down
1 change: 1 addition & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,7 @@ test5536(a::Union{Real, AbstractArray}) = "Non-splatting"
@test_throws LoadError include_string("#= #= #= =# =# =")

# issue #6142
import Base: +
type A6142 <: AbstractMatrix{Float64}; end
+{TJ}(x::A6142, y::UniformScaling{TJ}) = "UniformScaling method called"
+(x::A6142, y::AbstractArray) = "AbstractArray method called"
Expand Down
1 change: 1 addition & 0 deletions test/linalg/arnoldi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ end
size(Phi::CPM)=(size(Phi.kraus,1)^2,size(Phi.kraus,3)^2)
issym(Phi::CPM)=false
ishermitian(Phi::CPM)=false
import Base: *
function *{T<:Base.LinAlg.BlasFloat}(Phi::CPM{T},rho::Vector{T})
rho=reshape(rho,(size(Phi.kraus,3),size(Phi.kraus,3)))
rho2=zeros(T,(size(Phi.kraus,1),size(Phi.kraus,1)))
Expand Down

0 comments on commit 3bb7e2f

Please sign in to comment.