If the System` symbol you want to modify is a kernel function, then you can just use Clear
to reset it to its default state. For your Interval
example:
Language`ExtendedDefinition[Interval]
Language`DefinitionList[Interval->{OwnValues->{},SubValues->{},UpValues->{},DownValues->{},NValues->{},FormatValues->{},DefaultValues->{},Messages->{},Attributes->{Protected}}]
shows that Interval
has no *Values. Using Clear
on Interval
will only clear new definitions that you add. Example:
Unprotect[Interval];
Interval[n_Complex] := (#1 + #2*I) & @@ (Interval /@ ReIm[n])
Protect[Interval];
Now, let's check:
Language`ExtendedDefinition[Interval]
Language`DefinitionList[Interval->{OwnValues->{},SubValues->{},UpValues->{},DownValues->{HoldPattern[Interval[n_Complex]]:>(#1+#2 I&)@@Interval/@ReIm[n]},NValues->{},FormatValues->{},DefaultValues->{},Messages->{},Attributes->{Protected}}]
Notice that your definition shows up in the DownValues
rule. Let's clear definitions:
Unprotect[Interval];
Clear[Interval]
Protect[Interval];
And the definition is gone:
Language`ExtendedDefinition[Interval]
Language`DefinitionList[Interval->{OwnValues->{},SubValues->{},UpValues->{},DownValues->{},NValues->{},FormatValues->{},DefaultValues->{},Messages->{},Attributes->{Protected}}]
Note the Interval still works:
Sin[Interval[{0, Pi}]]
Interval[{0, 1}]
Interval[n_Complex] := (#1 + #2*I) & @@ (Interval /@ ReIm[n])
. Without this,Interval[n]
wheren
has headComplex
doesn't evaluate to anything. Unprotecting Interval and evaluating this works—I just want to do it safely and repeatedly in a package, which I think would involve resettingInterval
to the system default somehow. $\endgroup$