ClearAll¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
ClearAll[s1, s2, ...]
clears all values, definitions, attributes and messages for the named symbols. ClearAll[{s1, s2, ...}] accepts a list of specs.
Notes
ClearAll has attribute HoldAll; symbols with attribute Locked or Protected are not affected.Examples (3)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (3)¶
In[1]:= f[x_] := x^2; SetAttributes[f, Listable]; Attributes[f]
Out[1]= {Listable}
In[2]:= ClearAll[f]; {Attributes[f], DownValues[f]}
Out[2]= {{}, {}}
In[3]:= x = 2; Remove[x]; x
Out[3]= x
Implementation notes¶
ClearAllhas attributes{HoldAll, Protected};Removehas{HoldAll, Locked, Protected}. Both hold their arguments, so they operate on the symbol, not its current value.- Neither affects symbols with the attribute
LockedorProtected. This is what preventsRemove/ClearAllfrom ever deleting or wiping a built-in. ClearAll, unlikeClear, also removes attributes and the usage message.- Both return
Null.
Attributes: HoldAll, Protected.
References¶
- Source:
src/info.c - Specification:
docs/spec/builtins/assignment-and-rules.md - Tests:
tests/test_clearall_remove_protect.c - Tests:
tests/test_condition_downvalue.c - Tests:
tests/test_core.c - Tests:
tests/test_evaluate.c