Protect

Protect[s1,s2,]

sets the attribute Protected for the symbols si.

Protect["form1","form2",]

protects all symbols whose names match any of the string patterns formi.

Details

  • Protect allows abbreviated string patterns containing the following metacharacters:
  • *zero or more characters
    @one or more characters, excluding uppercase letters
    \\*, etc.literal *, etc.
  • Protect["context`*"] protects all symbols in a particular context.

Examples

open allclose all

Basic Examples  (1)

Define and protect a function:

The function definition can no longer be changed:

Scope  (2)

Protect several symbols:

Protect all symbols matching a string pattern:

Applications  (1)

Protect all symbols in the current context:

Properties & Relations  (4)

Protecting a symbol is equivalent to setting the Protected attribute:

Protect returns the list of symbols actually protected:

If a symbol is already protected, it is not protected again:

No more definitions can be made for a protected symbol:

To protect all symbols given in a variable, use Evaluate:

Introduced in 1988
 (1.0)