From 3c6554cf4e73095ae9e0f3730c5a0834032794b1 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Tue, 12 Dec 2017 02:00:50 +0100 Subject: [PATCH] remove workspace --- NEWS.md | 2 ++ base/exports.jl | 1 - base/interactiveutil.jl | 27 --------------- base/reflection.jl | 2 +- doc/src/manual/modules.md | 2 +- doc/src/stdlib/base.md | 1 - test/workspace.jl | 73 --------------------------------------- 7 files changed, 4 insertions(+), 104 deletions(-) delete mode 100644 test/workspace.jl diff --git a/NEWS.md b/NEWS.md index 7d1277a02dc3a6..81ba19cd8025c6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -732,6 +732,8 @@ Deprecated or removed * `trues(A::AbstractArray)` and `falses(A::AbstractArray)` are deprecated in favor of `trues(size(A))` and `falses(size(A))` respectively ([#24595]). + * `workspace` is discontinued ([#TBD]). + * `cumsum`, `cumprod`, `accumulate`, and their mutating versions now require a `dim` argument instead of defaulting to using the first dimension ([#24684]). diff --git a/base/exports.jl b/base/exports.jl index ed3f5d2b34b499..17ee6902ef0131 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -960,7 +960,6 @@ export varinfo, versioninfo, which, - workspace, @isdefined, # loading source files diff --git a/base/interactiveutil.jl b/base/interactiveutil.jl index fdad979f6b6648..5d71d8e0235c6c 100644 --- a/base/interactiveutil.jl +++ b/base/interactiveutil.jl @@ -666,33 +666,6 @@ functionality instead. """ download(url, filename) -# workspace management - -""" - workspace() - -Replace the top-level module (`Main`) with a new one, providing a clean workspace. The -previous `Main` module is made available as `LastMain`. - -If `Package` was previously loaded, `using Package` in the new `Main` will re-use the -loaded copy. Run `reload("Package")` first to load a fresh copy. - -This function should only be used interactively. -""" -function workspace() - last = Core.Main # ensure to reference the current Main module - b = Base # this module - ccall(:jl_new_main_module, Any, ()) # make Core.Main a new baremodule - m = Core.Main # now grab a handle to the new Main module - ccall(:jl_add_standard_imports, Void, (Any,), m) - eval(m, Expr(:toplevel, - :(const Base = $b), - :(const LastMain = $last), - :(using Base.MainInclude))) - empty!(package_locks) - return m -end - # testing """ diff --git a/base/reflection.jl b/base/reflection.jl index 63165a62226db1..26a339d843bc37 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -18,7 +18,7 @@ module_name(m::Module) = ccall(:jl_module_name, Ref{Symbol}, (Any,), m) """ module_parent(m::Module) -> Module -Get a module's enclosing `Module`. `Main` is its own parent, as is `LastMain` after `workspace()`. +Get a module's enclosing `Module`. `Main` is its own parent. # Examples ```jldoctest diff --git a/doc/src/manual/modules.md b/doc/src/manual/modules.md index e8bf887b56d99c..f1c8c9f780d89f 100644 --- a/doc/src/manual/modules.md +++ b/doc/src/manual/modules.md @@ -355,7 +355,7 @@ code to help the user avoid other wrong-behavior situations: emitted when the incremental precompile flag is set. 2. `global const` statements from local scope after `__init__()` has been started (see issue #12010 for plans to add an error for this) -3. Replacing a module (or calling [`workspace()`](@ref)) is a runtime error while doing an incremental precompile. +3. Replacing a module is a runtime error while doing an incremental precompile. A few other points to be aware of: diff --git a/doc/src/stdlib/base.md b/doc/src/stdlib/base.md index a7ec3f12dff974..3814b0af546a8c 100644 --- a/doc/src/stdlib/base.md +++ b/doc/src/stdlib/base.md @@ -48,7 +48,6 @@ Base.methods Base.methodswith Base.@show Base.versioninfo -Base.workspace ans ``` diff --git a/test/workspace.jl b/test/workspace.jl deleted file mode 100644 index 4b8c8bf18273fc..00000000000000 --- a/test/workspace.jl +++ /dev/null @@ -1,73 +0,0 @@ -# This file is a part of Julia. License is MIT: https://julialang.org/license - -using Test - -script = """ -# Issue #11948 -f(x) = x+1 -workspace() -@assert @__MODULE__() === Main -@assert isdefined(Main, :f) -@assert !@isdefined LastMain -@eval Core.Main begin - @assert @__MODULE__() === Main - @assert !isdefined(Main, :f) - LastMain.f(2) - - # PR #12990 - io = IOBuffer() - show(io, Pair) - @assert String(take!(io)) == "Pair" - @assert !Base.inbase(LastMain) -end -""" -exename = Base.julia_cmd() -@test success(pipeline(`$exename --startup-file=no -e $script`, stdout=STDOUT, stderr=STDERR)) - -# issue #17764 -script2 = """ -mutable struct Foo end -workspace() -@eval Core.Main begin - mutable struct Foo end - @assert Tuple{Type{LastMain.Foo}} !== Tuple{Type{Main.Foo}} -end -""" -@test success(pipeline(`$exename --startup-file=no -e $script2`, stdout=STDOUT, stderr=STDERR)) - -# Issue #22101 -mktempdir() do dir - withenv("JULIA_DEBUG_LOADING" => nothing) do - # We need to ensure that the module does a nontrivial amount of work during precompilation - write(joinpath(dir, "Test22101.jl"), """ - __precompile__() - module Test22101 - export f22101 - f22101() = collect(1:10) - f22101() - end - """) - write(joinpath(dir, "testdriver.jl"), """ - using Test - insert!(LOAD_PATH, 1, $(repr(dir))) - insert!(Base.LOAD_CACHE_PATH, 1, $(repr(dir))) - @test !isdefined(Main, :f22101) - @test !isdefined(Main, :LastMain) - begin - using Test22101 - @test isdefined(Main, :f22101) - @test f22101()::Vector{Int} == collect(1:10) - @eval workspace() using Test22101 - @test f22101()::Vector{Int} == collect(1:10) - @test isdefined(Main, :f22101) - end - @test isdefined(Main, :f22101) - @test !isdefined(Main, :LastMain) - @test isdefined(Core.Main, :f22101) - nothing - """) - # Ensure that STDIO doesn't get swallowed (helps with debugging) - cmd = `$(Base.julia_cmd()) --startup-file=no --sysimage-native-code=yes --compiled-modules=yes $(joinpath(dir, "testdriver.jl"))` - @test success(pipeline(cmd, stdout=STDOUT, stderr=STDERR)) - end -end