I use the command
ClearAll["Global`*"]
so much that I thought it would be nice to have a function that called it. Since by default ClearAll
requires an argument, I decided to overload it and have it so when no arguments are passed to ClearAll
it clears Global.
Unprotect[ClearAll]
ClearAll[]:=ClearAll["Global`*"];
Protect[ClearAll]
However, mathematica still expects an argument to the function, resulting in this
It still works fine, but is there any way to remove the red arrow? I've tried
SyntaxInformation[ClearAll] := {"ArgumentsPattern" -> {___}}
which should allow it to accept 0 arguments, but it still complains about it.
ClearAll[]
in global context, would not then callingClearAll[]
first time clears your ownClearAll[]
that you just defined? SinceClearAll
from the system is in the system contextContext[ClearAll]
. I agree with you, it will be nice to have a system command to clear all, without having to specify the context. I always mixes up the * and the ` order $\endgroup$ClearAll[] := ClearAll[$Context <> "*"]
$\endgroup$ClearAll[]
into a package which is loaded on startup. As part of theClearAll[]
definition I reload that package after the clear. That information doesn't really have to do with the question though, so I left it out. $\endgroup$ClearAll
is in theSystem`
context any definitions you attach to it will also be in theSystem`
context. $\endgroup$ClearAll::ssym: $Context<>* is not a symbol or a string. >>
" -- you probably wantClearAll @@ {$Context <> "*"}
$\endgroup$