In Mathematica, the documentation for ClearAll states:
ClearAll[symb1, symb2, ...]
clears values, definitions, attributes, messages, and defaults with symbols.
It also supports a similar format where it can clear any values / definitions which match an input string pattern:
ClearAll["form1", "form2", ...]
But there’s also the function Remove, for which the documentation says:
Remove[symbol1, ...]
removes symbols completely, so that their names are no longer recognized by Mathematica.
It also supports the same pattern based string input that ClearAll supports.
To me, it seems like both functions accomplish the same exact thing. Is there any practical difference to using one or the other?
I know that if I give an attribute to a symbol, Clear won’t remove it but ClearAll and Remove will. But it seems like Remove and ClearAll are doing the same thing.
ClearAllleaves the symbol in the symbol table:Removeremoves it from the symbol table:One reason to use
Removeinstead ofClearAllis if a symbol hides another symbol further down your $ContextPath. Here’s a contrived example:Another reason to use
Removeis that the notebook interface only includes known symbols when you choose Edit > Complete Selection (or on a Mac, press Command-K).