From 68ea6658d2107ec0df61cd55f186d204822d028c Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 2 Oct 2017 15:54:45 -0400 Subject: [PATCH] deprecate `importall`. fixes #22789 --- NEWS.md | 3 +++ base/deprecated.jl | 3 +++ base/docs/basedocs.jl | 9 --------- base/docs/utils.jl | 2 +- base/repl/REPLCompletions.jl | 2 +- base/show.jl | 2 +- doc/src/manual/faq.md | 11 ++++------- doc/src/manual/modules.md | 6 ------ src/toplevel.c | 2 ++ test/parse.jl | 2 -- test/show.jl | 2 -- 11 files changed, 15 insertions(+), 29 deletions(-) diff --git a/NEWS.md b/NEWS.md index 58bd5372cd8a3..77a3150a36e39 100644 --- a/NEWS.md +++ b/NEWS.md @@ -112,6 +112,9 @@ Language changes and `-` no longer do automatic broadcasting. Hence the methods for `UniformScaling` and `Number` are no longer deprecated ([#23923]). + * The keyword `importall` is deprecated. Use `using` and/or individual `import` statements + instead ([#22789]). + Breaking changes ---------------- diff --git a/base/deprecated.jl b/base/deprecated.jl index a30a688b2c8f5..70aa533b1a97f 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1637,6 +1637,9 @@ export hex2num # issue #5148, PR #23259 # warning for `const` on locals should be changed to an error in julia-syntax.scm +# issue #22789 +# remove code for `importall` in src/ + # issue #17886 # deprecations for filter[!] with 2-arg functions are in associative.jl diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 4725ac3523ee3..a7b98c1ef4ef1 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -143,15 +143,6 @@ Hello, Charlie! """ kw"macro" -""" - importall - -`importall` imports all names exported by the specified module, -as if `import` were used individually on all of them. -See the [manual section about modules](@ref modules) for details. -""" -kw"importall" - """ local diff --git a/base/docs/utils.jl b/base/docs/utils.jl index 7cf5b4f032462..f8739ca27cbf9 100644 --- a/base/docs/utils.jl +++ b/base/docs/utils.jl @@ -353,7 +353,7 @@ print_correction(word) = print_correction(STDOUT, word) const builtins = ["abstract type", "baremodule", "begin", "break", "catch", "ccall", "const", "continue", "do", "else", "elseif", "end", "export", "finally", "for", "function", - "global", "if", "import", "importall", "let", + "global", "if", "import", "let", "local", "macro", "module", "mutable struct", "primitive type", "quote", "return", "struct", "try", "using", "while"] diff --git a/base/repl/REPLCompletions.jl b/base/repl/REPLCompletions.jl index 6ba64e7a2152e..1e380b7150149 100644 --- a/base/repl/REPLCompletions.jl +++ b/base/repl/REPLCompletions.jl @@ -102,7 +102,7 @@ const sorted_keywords = [ "abstract type", "baremodule", "begin", "break", "catch", "ccall", "const", "continue", "do", "else", "elseif", "end", "export", "false", "finally", "for", "function", "global", "if", "import", - "importall", "let", "local", "macro", "module", "mutable struct", + "let", "local", "macro", "module", "mutable struct", "primitive type", "quote", "return", "struct", "true", "try", "using", "while"] diff --git a/base/show.jl b/base/show.jl index ce9f3eb17dff4..b4c284bffd39a 100644 --- a/base/show.jl +++ b/base/show.jl @@ -1182,7 +1182,7 @@ function show_unquoted(io::IO, ex::Expr, indent::Int, prec::Int) end parens && print(io, ")") - elseif head === :import || head === :importall || head === :using + elseif head === :import || head === :using print(io, head) first = true for a = args diff --git a/doc/src/manual/faq.md b/doc/src/manual/faq.md index 5ccf9d250acf7..7d677617269e9 100644 --- a/doc/src/manual/faq.md +++ b/doc/src/manual/faq.md @@ -561,21 +561,18 @@ julia> remotecall_fetch(anon_bar, 2) ## Packages and Modules -### What is the difference between "using" and "importall"? +### What is the difference between "using" and "import"? There is only one difference, and on the surface (syntax-wise) it may seem very minor. The difference -between `using` and `importall` is that with `using` you need to say `function Foo.bar(..` to -extend module Foo's function bar with a new method, but with `importall` or `import Foo.bar`, +between `using` and `import` is that with `using` you need to say `function Foo.bar(..` to +extend module Foo's function bar with a new method, but with `import Foo.bar`, you only need to say `function bar(...` and it automatically extends module Foo's function bar. -If you use `importall`, then `function Foo.bar(...` and `function bar(...` become equivalent. -If you use `using`, then they are different. - The reason this is important enough to have been given separate syntax is that you don't want to accidentally extend a function that you didn't know existed, because that could easily cause a bug. This is most likely to happen with a method that takes a common type like a string or integer, because both you and the other module could define a method to handle such a common type. If you -use `importall`, then you'll replace the other module's implementation of `bar(s::AbstractString)` +use `import`, then you'll replace the other module's implementation of `bar(s::AbstractString)` with your new implementation, which could easily do something completely different (and break all/many future usages of the other functions in module Foo that depend on calling bar). diff --git a/doc/src/manual/modules.md b/doc/src/manual/modules.md index 5a18c0083e9b3..1baf63368e5a2 100644 --- a/doc/src/manual/modules.md +++ b/doc/src/manual/modules.md @@ -17,8 +17,6 @@ using BigLib: thing1, thing2 import Base.show -importall OtherLib - export MyType, foo struct MyType @@ -53,9 +51,6 @@ from `using` in that functions must be imported using `import` to be extended wi In `MyModule` above we wanted to add a method to the standard `show` function, so we had to write `import Base.show`. Functions whose names are only visible via `using` cannot be extended. -The keyword `importall` explicitly imports all names exported by the specified module, as if -`import` were individually used on all of them. - Once a variable is made visible via `using` or `import`, a module may not create its own variable with the same name. Imported variables are read-only; assigning to a global variable always affects a variable owned by the current module, or else raises an error. @@ -89,7 +84,6 @@ functions into the current workspace: | `import MyModule` | `MyModule.x`, `MyModule.y` and `MyModule.p` | `MyModule.x`, `MyModule.y` and `MyModule.p` | | `import MyModule.x, MyModule.p` | `x` and `p` | `x` and `p` | | `import MyModule: x, p` | `x` and `p` | `x` and `p` | -| `importall MyModule` | All `export`ed names (`x` and `y`) | `x` and `y` | ### Modules and files diff --git a/src/toplevel.c b/src/toplevel.c index ea6d377380017..3bc5f4bd233fd 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -493,6 +493,8 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *m, jl_value_t *e, int fast, int e } else if (ex->head == importall_sym) { jl_sym_t *name = NULL; + jl_depwarn("`importall` is deprecated, use `using` or individual `import` statements instead", + (jl_value_t*)jl_symbol("importall")); jl_module_t *import = eval_import_path(m, ex->args, &name, "importall"); if (name != NULL) { import = (jl_module_t*)jl_eval_global_var(import, name); diff --git a/test/parse.jl b/test/parse.jl index 369585998667a..997c0343a0c8f 100644 --- a/test/parse.jl +++ b/test/parse.jl @@ -111,8 +111,6 @@ macro test999_str(args...); args; end Expr(:using, :A, :b), Expr(:using, :A, :c, :d))) -@test parse(":(importall A)") == Expr(:quote, Expr(:importall, :A)) - @test parse(":(import A)") == Expr(:quote, Expr(:import, :A)) @test parse(":(import A.b, B)") == Expr(:quote, Expr(:toplevel, diff --git a/test/show.jl b/test/show.jl index 8db3ce1da392b..ba95dcbd48e32 100644 --- a/test/show.jl +++ b/test/show.jl @@ -311,8 +311,6 @@ end @test_repr "baremodule X # line meta # line meta -importall ..A.b -# line meta import ...B.c # line meta import D