How do I clear all user defined symbols?
The normal way I reset the Mathematica kernel to its initial state is through the notebook interface:
Quit Kernel item,
Local submenu, then the
Quit confirmer button in the resulting dialog box. I do this often enough that my fingers know the drumbeat:
Alt-V Q L Q.
But I really need a way to set things back to normal from code. I suppose I could go
ClearAll /@ Names["Global`*"]
Remove /@ Names["Global`*"]
which does much of what I want, but seems really ham-handed to me, and doesn't really guarantee a complete system reset -- at least I don't think.
There is also the ancient
CleanSlate utility, which I can call from inside a notebook or package, but I have heard rumors that it's deprecated and unsupported:
My attempts to search the documentation and for something resembling
Clean yielded nothing useful.
EDIT: In case you're wondering, I want this for unit-testing big Packages, where I want to Reset in the unit-testing scripts so that I can have deterministic values for results of certain
EDIT: I found
Exit. That may be as close as we can get. I do not see any difference in them