workspace
workspace()
Replace the top-level module (Main
) with a new one, providing a clean workspace. The previous Main
module is made available as LastMain
. A previously-loaded package can be accessed using a statement such as using LastMain.Package
.
This function should only be used interactively.
Examples
workspace()
The workspace()
function in Julia replaces the top-level module (Main
) with a new one, providing a clean workspace. The previous Main
module is made available as LastMain
. It is important to note that this function should only be used interactively.
Example:
julia> x = 10
10
julia> workspace()
julia> x
ERROR: UndefVarError: x not defined
In this example, the workspace()
function is called after defining the variable x
. After calling workspace()
, the variable x
is no longer accessible since the workspace has been replaced.
Accessing previously-loaded packages:
julia> using LastMain.Package
If you had previously loaded a package in the previous Main
module before calling workspace()
, you can still access it using the using LastMain.Package
syntax. Replace Package
with the name of the package you want to access from the previous workspace (LastMain
).
It is important to note that using workspace()
will clear all variables, functions, and other objects defined in the previous workspace, providing a clean environment for new code execution.
See Also
assert, backtrace, code_llvm, code_lowered, code_native, code_typed, code_warntype, :@which, compilecache, current_module, eval, finalize, finalizer, fullname, function_module, function_name, include_dependency, InterruptException, invoke, isconst, isdefined, isgeneric, methodswith, method_exists, module_name, module_parent, require, subtypes, unsafe_load, workspace, __precompile__,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.