variable definitions - Different strategies to get a clean Kernel. Quit, Exit, ClearAll, Remove, CleanSlate?
Often new users face problems with lingering definitions that, if unaware, may cause unexpected and frustrating behaviour.
There are several answers that illustrate different aspects of the solution, but not a single place that can serve as a guide where the best strategies are compared side by side.
For example, in this answer @celtschk points to the need of using
ClearAll[Evaluate[$Context <> "*"]]
instead of
ClearAll["Global`*"]
in the cases when the Notebook has a Context
set to "unique to this Notebook".
This answer by @LeonidShifrin compares Remove
versus ClearAll
.
In this other answer @Szabolcs gives an extensive explanation to the "significant practical differences" between Quit
versus ClearAll["Global`*"]
.
And here @C.E. points to the use of
Needs["Utilities`CleanSlate`"]
CleanSlate[];
ClearInOut[];
Ultimately the advice seems to come to actually closing the kernel and starting one fresh, either via Exit
or Quit
.
Quit[]
But that doesn't cover preventive measures nor the possibility of a Dynamic
cell in the notebook, or initialization commands or any other mechanism that could re-spawn definitions.
Here I'm hoping for a canonical guide to the problem of a fresh kernel.
- Prevention
- New kernel
- Cleaning
Comments
Post a Comment