({{, (RefLink[Protected, paclet:ref/Protected])
is an attribute that prevents any values associated with a symbol from being modified. }})

OpenersNotesSection(Spacer1)Details

Many built-in Wolfram Language functions have the attribute (RefLink[Protected, paclet:ref/Protected]).

(RefLink[SetOptions, paclet:ref/SetOptions]) cannot be used on symbols with attribute (RefLink[Protected, paclet:ref/Protected]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Attributes[String]

f[x_]:=x^2;
Protect[f];

Attributes[f]

OpenersExampleSection1(Spacer1)Applications  (1)

Unprotect a system symbol to make a definition for it:

protected=Unprotect[Sqrt]

Sqrt[x_^2]:=x

Restore protection:

Protect[Evaluate[protected]]

OpenersExampleSection2(Spacer1)Properties & Relations  (4)

Protecting a symbol is equivalent to setting the (RefLink[Protected, paclet:ref/Protected]) attribute:

Protect[f];
SetAttributes[g,Protected];

Attributes[{f,g}]

Unprotecting a symbol is equivalent to clearing the (RefLink[Protected, paclet:ref/Protected]) attribute:

Unprotect[f];
ClearAttributes[g,Protected];

Attributes[{f,g}]

No more definitions can be made for a protected symbol:

f[x_]:=x^3

Protect[f];

f[x_]:=x^2

Neither can definitions be cleared:

Clear[f]

To modify definitions of a protected symbol, unprotect it first:

f[x_]:=x^2;
Protect[f];

f[x_]:=x^3

Unprotect[f];

f[x_]:=x^3

A symbol that is locked and protected can no longer be changed:

f[x_]:=x^2;
SetAttributes[f,{Locked,Protected}]

f[x_]:=x^3

Unprotect[f];

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Locked, paclet:ref/Locked])  ▪  (RefLink[ReadProtected, paclet:ref/ReadProtected])  ▪  (RefLink[Editable, paclet:ref/Editable])  ▪  (RefLink[PartProtection, paclet:ref/PartProtection])  ▪  (RefLink[Permissions, paclet:ref/Permissions])  ▪  (RefLink[ValuePreprocessingFunction, paclet:ref/ValuePreprocessingFunction])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Attributes, paclet:tutorial/Attributes])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Attributes, paclet:guide/Attributes])}, {▪(RefLinkPlain[Defining Variables and Functions, paclet:guide/VariablesAndFunctions])}})}})